From 7127fcd34a85e263e12fb9b970f2d9e30fe5bae8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 1 Jun 2022 08:26:19 +0000 Subject: [PATCH] CodeGen from PR 18942 in Azure/azure-rest-api-specs [Hub Generated] Publish private branch 'rolyon-permissions-extension-test-v1' (#18942) * Permissions for elevate access * Repositioned permissions section * Extension name change * Deleted extra spaces * Changed rolesWithThesePermissions to an array --- .../azure-mgmt-authorization/_meta.json | 10 +- .../_authorization_management_client.py | 131 +- .../mgmt/authorization/_configuration.py | 10 +- .../aio/_authorization_management_client.py | 132 +- .../mgmt/authorization/aio/_configuration.py | 10 +- .../azure/mgmt/authorization/models.py | 3 + .../authorization/v2015_06_01/__init__.py | 9 +- .../_authorization_management_client.py | 87 +- .../v2015_06_01/_configuration.py | 28 +- .../authorization/v2015_06_01/_metadata.json | 21 +- .../mgmt/authorization/v2015_06_01/_patch.py | 31 + .../mgmt/authorization/v2015_06_01/_vendor.py | 27 + .../authorization/v2015_06_01/_version.py | 2 +- .../authorization/v2015_06_01/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 75 +- .../v2015_06_01/aio/_configuration.py | 15 +- .../authorization/v2015_06_01/aio/_patch.py | 31 + .../_classic_administrators_operations.py | 72 +- .../v2015_06_01/models/__init__.py | 18 +- .../v2015_06_01/models/_models.py | 163 - .../v2015_06_01/models/_models_py3.py | 58 +- .../_classic_administrators_operations.py | 120 +- .../authorization/v2015_07_01/__init__.py | 9 +- .../_authorization_management_client.py | 123 +- .../v2015_07_01/_configuration.py | 28 +- .../authorization/v2015_07_01/_metadata.json | 21 +- .../mgmt/authorization/v2015_07_01/_patch.py | 31 + .../mgmt/authorization/v2015_07_01/_vendor.py | 27 + .../authorization/v2015_07_01/_version.py | 2 +- .../authorization/v2015_07_01/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 111 +- .../v2015_07_01/aio/_configuration.py | 15 +- .../authorization/v2015_07_01/aio/_patch.py | 31 + .../_classic_administrators_operations.py | 72 +- .../_global_administrator_operations.py | 49 +- .../aio/operations/_permissions_operations.py | 145 +- ...provider_operations_metadata_operations.py | 116 +- .../_role_assignments_operations.py | 566 +-- .../_role_definitions_operations.py | 252 +- .../v2015_07_01/models/__init__.py | 63 +- .../v2015_07_01/models/_models.py | 595 ---- .../v2015_07_01/models/_models_py3.py | 320 +- .../_classic_administrators_operations.py | 120 +- .../_global_administrator_operations.py | 91 +- .../operations/_permissions_operations.py | 250 +- ...provider_operations_metadata_operations.py | 208 +- .../_role_assignments_operations.py | 1041 ++++-- .../_role_definitions_operations.py | 486 ++- .../v2018_01_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 110 +- .../v2018_01_01_preview/_configuration.py | 28 +- .../v2018_01_01_preview/_metadata.json | 21 +- .../v2018_01_01_preview/_patch.py | 31 + .../v2018_01_01_preview/_vendor.py | 27 + .../v2018_01_01_preview/_version.py | 2 +- .../v2018_01_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 96 +- .../v2018_01_01_preview/aio/_configuration.py | 15 +- .../v2018_01_01_preview/aio/_patch.py | 31 + .../aio/operations/_permissions_operations.py | 145 +- ...provider_operations_metadata_operations.py | 116 +- .../_role_assignments_operations.py | 572 +-- .../_role_definitions_operations.py | 252 +- .../v2018_01_01_preview/models/__init__.py | 51 +- .../v2018_01_01_preview/models/_models.py | 521 --- .../v2018_01_01_preview/models/_models_py3.py | 306 +- .../operations/_permissions_operations.py | 250 +- ...provider_operations_metadata_operations.py | 208 +- .../_role_assignments_operations.py | 1047 ++++-- .../_role_definitions_operations.py | 486 ++- .../v2018_05_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 150 +- .../v2018_05_01_preview/_configuration.py | 28 +- .../v2018_05_01_preview/_metadata.json | 21 +- .../v2018_05_01_preview/_patch.py | 31 + .../v2018_05_01_preview/_vendor.py | 27 + .../v2018_05_01_preview/_version.py | 2 +- .../v2018_05_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 136 +- .../v2018_05_01_preview/aio/_configuration.py | 15 +- .../v2018_05_01_preview/aio/_patch.py | 31 + ...cess_review_default_settings_operations.py | 109 +- ...ss_review_instance_decisions_operations.py | 78 +- ...review_instance_my_decisions_operations.py | 178 +- .../_access_review_instance_operations.py | 244 +- ...ces_assigned_for_my_approval_operations.py | 113 +- .../_access_review_instances_operations.py | 118 +- ...ons_assigned_for_my_approval_operations.py | 64 +- ..._review_schedule_definitions_operations.py | 253 +- .../aio/operations/_operations.py | 61 +- .../v2018_05_01_preview/models/__init__.py | 60 +- .../_authorization_management_client_enums.py | 45 +- .../v2018_05_01_preview/models/_models.py | 1204 ------- .../v2018_05_01_preview/models/_models_py3.py | 708 ++-- ...cess_review_default_settings_operations.py | 205 +- ...ss_review_instance_decisions_operations.py | 134 +- ...review_instance_my_decisions_operations.py | 336 +- .../_access_review_instance_operations.py | 478 ++- ...ces_assigned_for_my_approval_operations.py | 205 +- .../_access_review_instances_operations.py | 210 +- ...ons_assigned_for_my_approval_operations.py | 106 +- ..._review_schedule_definitions_operations.py | 475 ++- .../operations/_operations.py | 103 +- .../v2018_07_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 87 +- .../v2018_07_01_preview/_configuration.py | 28 +- .../v2018_07_01_preview/_metadata.json | 21 +- .../v2018_07_01_preview/_patch.py | 31 + .../v2018_07_01_preview/_vendor.py | 27 + .../v2018_07_01_preview/_version.py | 2 +- .../v2018_07_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 75 +- .../v2018_07_01_preview/aio/_configuration.py | 15 +- .../v2018_07_01_preview/aio/_patch.py | 31 + .../_deny_assignments_operations.py | 376 +- .../v2018_07_01_preview/models/__init__.py | 27 +- .../v2018_07_01_preview/models/_models.py | 290 -- .../v2018_07_01_preview/models/_models_py3.py | 156 +- .../_deny_assignments_operations.py | 666 ++-- .../v2018_09_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 86 +- .../v2018_09_01_preview/_configuration.py | 28 +- .../v2018_09_01_preview/_metadata.json | 21 +- .../v2018_09_01_preview/_patch.py | 31 + .../v2018_09_01_preview/_vendor.py | 27 + .../v2018_09_01_preview/_version.py | 2 +- .../v2018_09_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 74 +- .../v2018_09_01_preview/aio/_configuration.py | 15 +- .../v2018_09_01_preview/aio/_patch.py | 31 + .../_role_assignments_operations.py | 572 +-- .../v2018_09_01_preview/models/__init__.py | 24 +- .../_authorization_management_client_enums.py | 21 +- .../v2018_09_01_preview/models/_models.py | 247 -- .../v2018_09_01_preview/models/_models_py3.py | 111 +- .../_role_assignments_operations.py | 1047 ++++-- .../v2019_08_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 86 +- .../v2019_08_01_preview/_configuration.py | 28 +- .../v2019_08_01_preview/_metadata.json | 21 +- .../v2019_08_01_preview/_patch.py | 31 + .../v2019_08_01_preview/_vendor.py | 27 + .../v2019_08_01_preview/_version.py | 2 +- .../v2019_08_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 74 +- .../v2019_08_01_preview/aio/_configuration.py | 15 +- .../v2019_08_01_preview/aio/_patch.py | 31 + .../_role_assignment_metrics_operations.py | 53 +- .../v2019_08_01_preview/models/__init__.py | 15 +- .../v2019_08_01_preview/models/_models.py | 145 - .../v2019_08_01_preview/models/_models_py3.py | 14 +- .../_role_assignment_metrics_operations.py | 101 +- .../v2020_04_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 86 +- .../v2020_04_01_preview/_configuration.py | 28 +- .../v2020_04_01_preview/_metadata.json | 21 +- .../v2020_04_01_preview/_patch.py | 31 + .../v2020_04_01_preview/_vendor.py | 27 + .../v2020_04_01_preview/_version.py | 2 +- .../v2020_04_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 74 +- .../v2020_04_01_preview/aio/_configuration.py | 15 +- .../v2020_04_01_preview/aio/_patch.py | 31 + .../_role_assignments_operations.py | 616 ++-- .../v2020_04_01_preview/models/__init__.py | 24 +- .../_authorization_management_client_enums.py | 21 +- .../v2020_04_01_preview/models/_models.py | 301 -- .../v2020_04_01_preview/models/_models_py3.py | 189 +- .../_role_assignments_operations.py | 1135 ++++-- .../authorization/v2020_10_01/__init__.py | 18 + .../_authorization_management_client.py | 128 + .../v2020_10_01/_configuration.py | 67 + .../authorization/v2020_10_01/_metadata.json | 98 + .../mgmt/authorization/v2020_10_01/_patch.py | 31 + .../mgmt/authorization/v2020_10_01/_vendor.py | 27 + .../authorization/v2020_10_01/_version.py | 9 + .../authorization/v2020_10_01/aio/__init__.py | 15 + .../aio/_authorization_management_client.py | 125 + .../v2020_10_01/aio/_configuration.py | 66 + .../authorization/v2020_10_01/aio/_patch.py | 31 + .../v2020_10_01/aio/operations/__init__.py | 29 + .../_eligible_child_resources_operations.py | 129 + ...ssignment_schedule_instances_operations.py | 190 + ...assignment_schedule_requests_operations.py | 380 ++ .../_role_assignment_schedules_operations.py | 189 + ...igibility_schedule_instances_operations.py | 190 + ...ligibility_schedule_requests_operations.py | 380 ++ .../_role_eligibility_schedules_operations.py | 189 + .../_role_management_policies_operations.py | 296 ++ ...anagement_policy_assignments_operations.py | 299 ++ .../v2020_10_01/models/__init__.py | 147 + .../_authorization_management_client_enums.py | 142 + .../v2020_10_01/models/_models_py3.py | 3119 +++++++++++++++++ .../v2020_10_01/operations/__init__.py | 29 + .../_eligible_child_resources_operations.py | 168 + ...ssignment_schedule_instances_operations.py | 262 ++ ...assignment_schedule_requests_operations.py | 571 +++ .../_role_assignment_schedules_operations.py | 261 ++ ...igibility_schedule_instances_operations.py | 262 ++ ...ligibility_schedule_requests_operations.py | 571 +++ .../_role_eligibility_schedules_operations.py | 261 ++ .../_role_management_policies_operations.py | 441 +++ ...anagement_policy_assignments_operations.py | 444 +++ .../mgmt/authorization/v2020_10_01/py.typed | 1 + .../v2020_10_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 158 +- .../v2020_10_01_preview/_configuration.py | 28 +- .../v2020_10_01_preview/_metadata.json | 21 +- .../v2020_10_01_preview/_patch.py | 31 + .../v2020_10_01_preview/_vendor.py | 27 + .../v2020_10_01_preview/_version.py | 2 +- .../v2020_10_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 144 +- .../v2020_10_01_preview/aio/_configuration.py | 15 +- .../v2020_10_01_preview/aio/_patch.py | 31 + .../_eligible_child_resources_operations.py | 76 +- ...ssignment_schedule_instances_operations.py | 115 +- ...assignment_schedule_requests_operations.py | 214 +- .../_role_assignment_schedules_operations.py | 114 +- .../_role_assignments_operations.py | 723 ++-- ...igibility_schedule_instances_operations.py | 114 +- ...ligibility_schedule_requests_operations.py | 210 +- .../_role_eligibility_schedules_operations.py | 114 +- .../_role_management_policies_operations.py | 201 +- ...anagement_policy_assignments_operations.py | 204 +- .../v2020_10_01_preview/models/__init__.py | 189 +- .../_authorization_management_client_enums.py | 45 +- .../v2020_10_01_preview/models/_models.py | 2581 -------------- .../v2020_10_01_preview/models/_models_py3.py | 1783 +++++++--- .../_eligible_child_resources_operations.py | 132 +- ...ssignment_schedule_instances_operations.py | 209 +- ...assignment_schedule_requests_operations.py | 409 ++- .../_role_assignment_schedules_operations.py | 208 +- .../_role_assignments_operations.py | 1340 ++++--- ...igibility_schedule_instances_operations.py | 208 +- ...ligibility_schedule_requests_operations.py | 405 ++- .../_role_eligibility_schedules_operations.py | 208 +- .../_role_management_policies_operations.py | 390 ++- ...anagement_policy_assignments_operations.py | 393 ++- .../v2021_01_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 126 +- .../v2021_01_01_preview/_configuration.py | 26 +- .../v2021_01_01_preview/_metadata.json | 21 +- .../v2021_01_01_preview/_patch.py | 31 + .../v2021_01_01_preview/_vendor.py | 27 + .../v2021_01_01_preview/_version.py | 2 +- .../v2021_01_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 116 +- .../v2021_01_01_preview/aio/_configuration.py | 15 +- .../v2021_01_01_preview/aio/_patch.py | 31 + .../aio/operations/_operations.py | 61 +- .../_role_assignment_approval_operations.py | 111 +- ...ole_assignment_approval_step_operations.py | 171 +- ...le_assignment_approval_steps_operations.py | 56 +- ...ope_role_assignment_approval_operations.py | 119 +- ...ole_assignment_approval_step_operations.py | 177 +- ...le_assignment_approval_steps_operations.py | 58 +- .../v2021_01_01_preview/models/__init__.py | 33 +- .../_authorization_management_client_enums.py | 25 +- .../v2021_01_01_preview/models/_models.py | 416 --- .../v2021_01_01_preview/models/_models_py3.py | 133 +- .../operations/_operations.py | 103 +- .../_role_assignment_approval_operations.py | 197 +- ...ole_assignment_approval_step_operations.py | 332 +- ...le_assignment_approval_steps_operations.py | 106 +- ...ope_role_assignment_approval_operations.py | 213 +- ...ole_assignment_approval_step_operations.py | 350 +- ...le_assignment_approval_steps_operations.py | 112 +- .../v2021_03_01_preview/__init__.py | 9 +- .../_authorization_management_client.py | 150 +- .../v2021_03_01_preview/_configuration.py | 28 +- .../v2021_03_01_preview/_metadata.json | 21 +- .../v2021_03_01_preview/_patch.py | 31 + .../v2021_03_01_preview/_vendor.py | 27 + .../v2021_03_01_preview/_version.py | 2 +- .../v2021_03_01_preview/aio/__init__.py | 5 + .../aio/_authorization_management_client.py | 136 +- .../v2021_03_01_preview/aio/_configuration.py | 15 +- .../v2021_03_01_preview/aio/_patch.py | 31 + ...cess_review_default_settings_operations.py | 109 +- ...ss_review_instance_decisions_operations.py | 84 +- ...review_instance_my_decisions_operations.py | 184 +- .../_access_review_instance_operations.py | 244 +- ...ces_assigned_for_my_approval_operations.py | 119 +- .../_access_review_instances_operations.py | 124 +- ...ons_assigned_for_my_approval_operations.py | 72 +- ..._review_schedule_definitions_operations.py | 259 +- .../aio/operations/_operations.py | 61 +- .../v2021_03_01_preview/models/__init__.py | 63 +- .../_authorization_management_client_enums.py | 49 +- .../v2021_03_01_preview/models/_models.py | 1352 ------- .../v2021_03_01_preview/models/_models_py3.py | 757 ++-- ...cess_review_default_settings_operations.py | 205 +- ...ss_review_instance_decisions_operations.py | 146 +- ...review_instance_my_decisions_operations.py | 348 +- .../_access_review_instance_operations.py | 478 ++- ...ces_assigned_for_my_approval_operations.py | 213 +- .../_access_review_instances_operations.py | 222 +- ...ons_assigned_for_my_approval_operations.py | 120 +- ..._review_schedule_definitions_operations.py | 487 ++- .../operations/_operations.py | 103 +- .../v2021_07_01_preview/__init__.py | 18 + .../_authorization_management_client.py | 140 + .../v2021_07_01_preview/_configuration.py | 73 + .../v2021_07_01_preview/_metadata.json | 112 + .../v2021_07_01_preview/_patch.py | 31 + .../v2021_07_01_preview/_vendor.py | 27 + .../v2021_07_01_preview/_version.py | 9 + .../v2021_07_01_preview/aio/__init__.py | 15 + .../aio/_authorization_management_client.py | 137 + .../v2021_07_01_preview/aio/_configuration.py | 72 + .../v2021_07_01_preview/aio/_patch.py | 31 + .../aio/operations/__init__.py | 33 + ...cess_review_default_settings_operations.py | 154 + ...instance_contacted_reviewers_operations.py | 129 + ...ss_review_instance_decisions_operations.py | 137 + ...review_instance_my_decisions_operations.py | 268 ++ .../_access_review_instance_operations.py | 318 ++ ...ces_assigned_for_my_approval_operations.py | 189 + .../_access_review_instances_operations.py | 259 ++ ...ons_assigned_for_my_approval_operations.py | 125 + ..._review_schedule_definitions_operations.py | 348 ++ .../aio/operations/_operations.py | 116 + ...instance_contacted_reviewers_operations.py | 127 + .../v2021_07_01_preview/models/__init__.py | 93 + .../_authorization_management_client_enums.py | 161 + .../v2021_07_01_preview/models/_models_py3.py | 2061 +++++++++++ .../operations/__init__.py | 33 + ...cess_review_default_settings_operations.py | 230 ++ ...instance_contacted_reviewers_operations.py | 168 + ...ss_review_instance_decisions_operations.py | 180 + ...review_instance_my_decisions_operations.py | 389 ++ .../_access_review_instance_operations.py | 499 +++ ...ces_assigned_for_my_approval_operations.py | 261 ++ .../_access_review_instances_operations.py | 380 ++ ...ons_assigned_for_my_approval_operations.py | 158 + ..._review_schedule_definitions_operations.py | 531 +++ .../operations/_operations.py | 145 + ...instance_contacted_reviewers_operations.py | 164 + .../v2021_07_01_preview/py.typed | 1 + 340 files changed, 41035 insertions(+), 20919 deletions(-) create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py delete mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py create mode 100644 sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed diff --git a/sdk/authorization/azure-mgmt-authorization/_meta.json b/sdk/authorization/azure-mgmt-authorization/_meta.json index 93b83d2d4425..8c253ba3dcf1 100644 --- a/sdk/authorization/azure-mgmt-authorization/_meta.json +++ b/sdk/authorization/azure-mgmt-authorization/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.13.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "ac1c84fa8c897975b88a38a66dd64d54312a1422", + "commit": "688cfd36391115f70ea9276a8e526caea6a5c8ad", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/authorization/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/authorization/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/authorization/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py index b276347dde37..6cb0f683a604 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_authorization_management_client.py @@ -11,10 +11,11 @@ from typing import TYPE_CHECKING +from msrest import Deserializer, Serializer + from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration @@ -23,7 +24,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs): pass class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. + """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). @@ -45,8 +45,6 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :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 api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str :param base_url: Service URL @@ -55,11 +53,19 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2015-07-01' + DEFAULT_API_VERSION = '2020-10-01' _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, + 'classic_administrators': '2015-07-01', + 'deny_assignments': '2018-07-01-preview', + 'global_administrator': '2015-07-01', + 'permissions': '2015-07-01', + 'provider_operations_metadata': '2015-07-01', + 'role_assignment_metrics': '2019-08-01-preview', + 'role_assignments': '2015-07-01', + 'role_definitions': '2015-07-01', }}, _PROFILE_TAG + " latest" ) @@ -67,15 +73,12 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, credential, # type: "TokenCredential" - subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, @@ -98,9 +101,11 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-09-01-preview: :mod:`v2018_09_01_preview.models` * 2019-08-01-preview: :mod:`v2019_08_01_preview.models` * 2020-04-01-preview: :mod:`v2020_04_01_preview.models` + * 2020-10-01: :mod:`v2020_10_01.models` * 2020-10-01-preview: :mod:`v2020_10_01_preview.models` * 2021-01-01-preview: :mod:`v2021_01_01_preview.models` * 2021-03-01-preview: :mod:`v2021_03_01_preview.models` + * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` """ if api_version == '2015-06-01': from .v2015_06_01 import models @@ -126,6 +131,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-04-01-preview': from .v2020_04_01_preview import models return models + elif api_version == '2020-10-01': + from .v2020_10_01 import models + return models elif api_version == '2020-10-01-preview': from .v2020_10_01_preview import models return models @@ -135,6 +143,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-03-01-preview': from .v2021_03_01_preview import models return models + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -143,12 +154,15 @@ def access_review_default_settings(self): * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations` * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations` + * 2021-07-01-preview: :class:`AccessReviewDefaultSettingsOperations` """ api_version = self._get_api_version('access_review_default_settings') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewDefaultSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_default_settings'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -159,28 +173,47 @@ def access_review_instance(self): * 2018-05-01-preview: :class:`AccessReviewInstanceOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceOperations` + * 2021-07-01-preview: :class:`AccessReviewInstanceOperations` """ api_version = self._get_api_version('access_review_instance') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewInstanceOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def access_review_instance_contacted_reviewers(self): + """Instance depends on the API version: + + * 2021-07-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations` + """ + api_version = self._get_api_version('access_review_instance_contacted_reviewers') + if api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'access_review_instance_contacted_reviewers'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def access_review_instance_decisions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceDecisionsOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceDecisionsOperations` + * 2021-07-01-preview: :class:`AccessReviewInstanceDecisionsOperations` """ api_version = self._get_api_version('access_review_instance_decisions') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewInstanceDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_decisions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -191,12 +224,15 @@ def access_review_instance_my_decisions(self): * 2018-05-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` + * 2021-07-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` """ api_version = self._get_api_version('access_review_instance_my_decisions') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_my_decisions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -207,12 +243,15 @@ def access_review_instances(self): * 2018-05-01-preview: :class:`AccessReviewInstancesOperations` * 2021-03-01-preview: :class:`AccessReviewInstancesOperations` + * 2021-07-01-preview: :class:`AccessReviewInstancesOperations` """ api_version = self._get_api_version('access_review_instances') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewInstancesOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -223,12 +262,15 @@ def access_review_instances_assigned_for_my_approval(self): * 2018-05-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` * 2021-03-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` + * 2021-07-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` """ api_version = self._get_api_version('access_review_instances_assigned_for_my_approval') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances_assigned_for_my_approval'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -239,12 +281,15 @@ def access_review_schedule_definitions(self): * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` + * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` """ api_version = self._get_api_version('access_review_schedule_definitions') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewScheduleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -255,12 +300,15 @@ def access_review_schedule_definitions_assigned_for_my_approval(self): * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` + * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` """ api_version = self._get_api_version('access_review_schedule_definitions_assigned_for_my_approval') if api_version == '2018-05-01-preview': from .v2018_05_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions_assigned_for_my_approval'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -298,10 +346,13 @@ def deny_assignments(self): def eligible_child_resources(self): """Instance depends on the API version: + * 2020-10-01: :class:`EligibleChildResourcesOperations` * 2020-10-01-preview: :class:`EligibleChildResourcesOperations` """ api_version = self._get_api_version('eligible_child_resources') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import EligibleChildResourcesOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import EligibleChildResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'eligible_child_resources'".format(api_version)) @@ -327,6 +378,7 @@ def operations(self): * 2018-05-01-preview: :class:`Operations` * 2021-01-01-preview: :class:`Operations` * 2021-03-01-preview: :class:`Operations` + * 2021-07-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01-preview': @@ -335,6 +387,8 @@ def operations(self): from .v2021_01_01_preview.operations import Operations as OperationClass elif api_version == '2021-03-01-preview': from .v2021_03_01_preview.operations import Operations as OperationClass + elif api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -427,10 +481,13 @@ def role_assignment_metrics(self): def role_assignment_schedule_instances(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentScheduleInstancesOperations` * 2020-10-01-preview: :class:`RoleAssignmentScheduleInstancesOperations` """ api_version = self._get_api_version('role_assignment_schedule_instances') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleAssignmentScheduleInstancesOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleAssignmentScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_instances'".format(api_version)) @@ -440,10 +497,13 @@ def role_assignment_schedule_instances(self): def role_assignment_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` """ api_version = self._get_api_version('role_assignment_schedule_requests') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleAssignmentScheduleRequestsOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleAssignmentScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) @@ -453,10 +513,13 @@ def role_assignment_schedule_requests(self): def role_assignment_schedules(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentSchedulesOperations` * 2020-10-01-preview: :class:`RoleAssignmentSchedulesOperations` """ api_version = self._get_api_version('role_assignment_schedules') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleAssignmentSchedulesOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleAssignmentSchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedules'".format(api_version)) @@ -507,10 +570,13 @@ def role_definitions(self): def role_eligibility_schedule_instances(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilityScheduleInstancesOperations` * 2020-10-01-preview: :class:`RoleEligibilityScheduleInstancesOperations` """ api_version = self._get_api_version('role_eligibility_schedule_instances') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleEligibilityScheduleInstancesOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleEligibilityScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_instances'".format(api_version)) @@ -520,10 +586,13 @@ def role_eligibility_schedule_instances(self): def role_eligibility_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` """ api_version = self._get_api_version('role_eligibility_schedule_requests') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleEligibilityScheduleRequestsOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleEligibilityScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) @@ -533,10 +602,13 @@ def role_eligibility_schedule_requests(self): def role_eligibility_schedules(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilitySchedulesOperations` * 2020-10-01-preview: :class:`RoleEligibilitySchedulesOperations` """ api_version = self._get_api_version('role_eligibility_schedules') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleEligibilitySchedulesOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleEligibilitySchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedules'".format(api_version)) @@ -546,10 +618,13 @@ def role_eligibility_schedules(self): def role_management_policies(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleManagementPoliciesOperations` * 2020-10-01-preview: :class:`RoleManagementPoliciesOperations` """ api_version = self._get_api_version('role_management_policies') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleManagementPoliciesOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policies'".format(api_version)) @@ -559,10 +634,13 @@ def role_management_policies(self): def role_management_policy_assignments(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleManagementPolicyAssignmentsOperations` * 2020-10-01-preview: :class:`RoleManagementPolicyAssignmentsOperations` """ api_version = self._get_api_version('role_management_policy_assignments') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from .v2020_10_01.operations import RoleManagementPolicyAssignmentsOperations as OperationClass + elif api_version == '2020-10-01-preview': from .v2020_10_01_preview.operations import RoleManagementPolicyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policy_assignments'".format(api_version)) @@ -607,6 +685,19 @@ def scope_role_assignment_approval_steps(self): raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def tenant_level_access_review_instance_contacted_reviewers(self): + """Instance depends on the API version: + + * 2021-07-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations` + """ + api_version = self._get_api_version('tenant_level_access_review_instance_contacted_reviewers') + if api_version == '2021-07-01-preview': + from .v2021_07_01_preview.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'tenant_level_access_review_instance_contacted_reviewers'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + def close(self): self._client.close() def __enter__(self): diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py index 23336d3cc79e..64f8e7858df0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -30,25 +30,19 @@ class AuthorizationManagementClientConfiguration(Configuration): :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 """ def __init__( 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.") super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +62,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py index 931b122b8db7..1139debc943d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_authorization_management_client.py @@ -11,16 +11,17 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from msrest import Deserializer, Serializer + from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin -from msrest import Deserializer, Serializer from ._configuration import AuthorizationManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -31,7 +32,7 @@ def __init__(self, *args, **kwargs): pass class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. + """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. This ready contains multiple API versions, to help you deal with all of the Azure clouds (Azure Stack, Azure Government, Azure China, etc.). @@ -43,8 +44,6 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :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 api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str :param base_url: Service URL @@ -53,11 +52,19 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2015-07-01' + DEFAULT_API_VERSION = '2020-10-01' _PROFILE_TAG = "azure.mgmt.authorization.AuthorizationManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, + 'classic_administrators': '2015-07-01', + 'deny_assignments': '2018-07-01-preview', + 'global_administrator': '2015-07-01', + 'permissions': '2015-07-01', + 'provider_operations_metadata': '2015-07-01', + 'role_assignment_metrics': '2019-08-01-preview', + 'role_assignments': '2015-07-01', + 'role_definitions': '2015-07-01', }}, _PROFILE_TAG + " latest" ) @@ -65,15 +72,12 @@ class AuthorizationManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, credential: "AsyncTokenCredential", - subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(AuthorizationManagementClient, self).__init__( api_version=api_version, @@ -96,9 +100,11 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2018-09-01-preview: :mod:`v2018_09_01_preview.models` * 2019-08-01-preview: :mod:`v2019_08_01_preview.models` * 2020-04-01-preview: :mod:`v2020_04_01_preview.models` + * 2020-10-01: :mod:`v2020_10_01.models` * 2020-10-01-preview: :mod:`v2020_10_01_preview.models` * 2021-01-01-preview: :mod:`v2021_01_01_preview.models` * 2021-03-01-preview: :mod:`v2021_03_01_preview.models` + * 2021-07-01-preview: :mod:`v2021_07_01_preview.models` """ if api_version == '2015-06-01': from ..v2015_06_01 import models @@ -124,6 +130,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-04-01-preview': from ..v2020_04_01_preview import models return models + elif api_version == '2020-10-01': + from ..v2020_10_01 import models + return models elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview import models return models @@ -133,6 +142,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview import models return models + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -141,12 +153,15 @@ def access_review_default_settings(self): * 2018-05-01-preview: :class:`AccessReviewDefaultSettingsOperations` * 2021-03-01-preview: :class:`AccessReviewDefaultSettingsOperations` + * 2021-07-01-preview: :class:`AccessReviewDefaultSettingsOperations` """ api_version = self._get_api_version('access_review_default_settings') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewDefaultSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_default_settings'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -157,28 +172,47 @@ def access_review_instance(self): * 2018-05-01-preview: :class:`AccessReviewInstanceOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceOperations` + * 2021-07-01-preview: :class:`AccessReviewInstanceOperations` """ api_version = self._get_api_version('access_review_instance') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def access_review_instance_contacted_reviewers(self): + """Instance depends on the API version: + + * 2021-07-01-preview: :class:`AccessReviewInstanceContactedReviewersOperations` + """ + api_version = self._get_api_version('access_review_instance_contacted_reviewers') + if api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceContactedReviewersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'access_review_instance_contacted_reviewers'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property def access_review_instance_decisions(self): """Instance depends on the API version: * 2018-05-01-preview: :class:`AccessReviewInstanceDecisionsOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceDecisionsOperations` + * 2021-07-01-preview: :class:`AccessReviewInstanceDecisionsOperations` """ api_version = self._get_api_version('access_review_instance_decisions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_decisions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -189,12 +223,15 @@ def access_review_instance_my_decisions(self): * 2018-05-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` * 2021-03-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` + * 2021-07-01-preview: :class:`AccessReviewInstanceMyDecisionsOperations` """ api_version = self._get_api_version('access_review_instance_my_decisions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewInstanceMyDecisionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instance_my_decisions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -205,12 +242,15 @@ def access_review_instances(self): * 2018-05-01-preview: :class:`AccessReviewInstancesOperations` * 2021-03-01-preview: :class:`AccessReviewInstancesOperations` + * 2021-07-01-preview: :class:`AccessReviewInstancesOperations` """ api_version = self._get_api_version('access_review_instances') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -221,12 +261,15 @@ def access_review_instances_assigned_for_my_approval(self): * 2018-05-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` * 2021-03-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` + * 2021-07-01-preview: :class:`AccessReviewInstancesAssignedForMyApprovalOperations` """ api_version = self._get_api_version('access_review_instances_assigned_for_my_approval') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewInstancesAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_instances_assigned_for_my_approval'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -237,12 +280,15 @@ def access_review_schedule_definitions(self): * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` + * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsOperations` """ api_version = self._get_api_version('access_review_schedule_definitions') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -253,12 +299,15 @@ def access_review_schedule_definitions_assigned_for_my_approval(self): * 2018-05-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` * 2021-03-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` + * 2021-07-01-preview: :class:`AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations` """ api_version = self._get_api_version('access_review_schedule_definitions_assigned_for_my_approval') if api_version == '2018-05-01-preview': from ..v2018_05_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'access_review_schedule_definitions_assigned_for_my_approval'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -296,10 +345,13 @@ def deny_assignments(self): def eligible_child_resources(self): """Instance depends on the API version: + * 2020-10-01: :class:`EligibleChildResourcesOperations` * 2020-10-01-preview: :class:`EligibleChildResourcesOperations` """ api_version = self._get_api_version('eligible_child_resources') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import EligibleChildResourcesOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import EligibleChildResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'eligible_child_resources'".format(api_version)) @@ -325,6 +377,7 @@ def operations(self): * 2018-05-01-preview: :class:`Operations` * 2021-01-01-preview: :class:`Operations` * 2021-03-01-preview: :class:`Operations` + * 2021-07-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2018-05-01-preview': @@ -333,6 +386,8 @@ def operations(self): from ..v2021_01_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-03-01-preview': from ..v2021_03_01_preview.aio.operations import Operations as OperationClass + elif api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @@ -425,10 +480,13 @@ def role_assignment_metrics(self): def role_assignment_schedule_instances(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentScheduleInstancesOperations` * 2020-10-01-preview: :class:`RoleAssignmentScheduleInstancesOperations` """ api_version = self._get_api_version('role_assignment_schedule_instances') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_instances'".format(api_version)) @@ -438,10 +496,13 @@ def role_assignment_schedule_instances(self): def role_assignment_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleAssignmentScheduleRequestsOperations` """ api_version = self._get_api_version('role_assignment_schedule_requests') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedule_requests'".format(api_version)) @@ -451,10 +512,13 @@ def role_assignment_schedule_requests(self): def role_assignment_schedules(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleAssignmentSchedulesOperations` * 2020-10-01-preview: :class:`RoleAssignmentSchedulesOperations` """ api_version = self._get_api_version('role_assignment_schedules') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleAssignmentSchedulesOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleAssignmentSchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_assignment_schedules'".format(api_version)) @@ -505,10 +569,13 @@ def role_definitions(self): def role_eligibility_schedule_instances(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilityScheduleInstancesOperations` * 2020-10-01-preview: :class:`RoleEligibilityScheduleInstancesOperations` """ api_version = self._get_api_version('role_eligibility_schedule_instances') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleInstancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_instances'".format(api_version)) @@ -518,10 +585,13 @@ def role_eligibility_schedule_instances(self): def role_eligibility_schedule_requests(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilityScheduleRequestsOperations` * 2020-10-01-preview: :class:`RoleEligibilityScheduleRequestsOperations` """ api_version = self._get_api_version('role_eligibility_schedule_requests') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilityScheduleRequestsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedule_requests'".format(api_version)) @@ -531,10 +601,13 @@ def role_eligibility_schedule_requests(self): def role_eligibility_schedules(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleEligibilitySchedulesOperations` * 2020-10-01-preview: :class:`RoleEligibilitySchedulesOperations` """ api_version = self._get_api_version('role_eligibility_schedules') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleEligibilitySchedulesOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleEligibilitySchedulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_eligibility_schedules'".format(api_version)) @@ -544,10 +617,13 @@ def role_eligibility_schedules(self): def role_management_policies(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleManagementPoliciesOperations` * 2020-10-01-preview: :class:`RoleManagementPoliciesOperations` """ api_version = self._get_api_version('role_management_policies') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleManagementPoliciesOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policies'".format(api_version)) @@ -557,10 +633,13 @@ def role_management_policies(self): def role_management_policy_assignments(self): """Instance depends on the API version: + * 2020-10-01: :class:`RoleManagementPolicyAssignmentsOperations` * 2020-10-01-preview: :class:`RoleManagementPolicyAssignmentsOperations` """ api_version = self._get_api_version('role_management_policy_assignments') - if api_version == '2020-10-01-preview': + if api_version == '2020-10-01': + from ..v2020_10_01.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass + elif api_version == '2020-10-01-preview': from ..v2020_10_01_preview.aio.operations import RoleManagementPolicyAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'role_management_policy_assignments'".format(api_version)) @@ -605,6 +684,19 @@ def scope_role_assignment_approval_steps(self): raise ValueError("API version {} does not have operation group 'scope_role_assignment_approval_steps'".format(api_version)) return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + @property + def tenant_level_access_review_instance_contacted_reviewers(self): + """Instance depends on the API version: + + * 2021-07-01-preview: :class:`TenantLevelAccessReviewInstanceContactedReviewersOperations` + """ + api_version = self._get_api_version('tenant_level_access_review_instance_contacted_reviewers') + if api_version == '2021-07-01-preview': + from ..v2021_07_01_preview.aio.operations import TenantLevelAccessReviewInstanceContactedReviewersOperations as OperationClass + else: + raise ValueError("API version {} does not have operation group 'tenant_level_access_review_instance_contacted_reviewers'".format(api_version)) + return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) + async def close(self): await self._client.close() async def __aenter__(self): diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py index cf4c9ef9bf99..055b4024ff39 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/aio/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -28,24 +28,18 @@ class AuthorizationManagementClientConfiguration(Configuration): :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 # type: 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.subscription_id = subscription_id self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'azure-mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +58,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py index 3fc87a882b88..b51c857f3afa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/models.py @@ -5,3 +5,6 @@ # license information. # -------------------------------------------------------------------------- from .v2015_07_01.models import * +from .v2018_07_01_preview.models import * +from .v2019_08_01_preview.models import * +from .v2020_10_01.models import * diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py index 0dca81078c2d..e86505659f42 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_authorization_management_client.py @@ -6,73 +6,84 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + definitions and role assignments. A role definition describes the set of actions that can be + performed on resources. A role assignment grants access to Azure Active Directory users. :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations + :vartype classic_administrators: + azure.mgmt.authorization.v2015_06_01.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.classic_administrators = ClassicAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py index 9f3e1d521653..e000eba5742b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json index 93f9a8785b8c..84208c274954 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "classic_administrators": "ClassicAdministratorsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py index cb8cddb257ed..3f8a4f329c81 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_authorization_management_client.py @@ -6,69 +6,84 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import ClassicAdministratorsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + definitions and role assignments. A role definition describes the set of actions that can be + performed on resources. A role assignment grants access to Azure Active Directory users. :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations + :vartype classic_administrators: + azure.mgmt.authorization.v2015_06_01.aio.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.classic_administrators = ClassicAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py index 1310486fc391..7de898450f46 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-06-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-06-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py index 824b5fc117b3..51fe3a95b132 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/aio/operations/_classic_administrators_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._classic_administrators_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,43 +52,44 @@ def list( """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +98,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py index 32a64afe5356..2a13108c87ae 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/__init__.py @@ -6,18 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ClassicAdministrator - from ._models_py3 import ClassicAdministratorListResult - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse -except (SyntaxError, ImportError): - from ._models import ClassicAdministrator # type: ignore - from ._models import ClassicAdministratorListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore +from ._models_py3 import ClassicAdministrator +from ._models_py3 import ClassicAdministratorListResult +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse + __all__ = [ 'ClassicAdministrator', diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py deleted file mode 100644 index fcb7089a6617..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models.py +++ /dev/null @@ -1,163 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ClassicAdministrator(msrest.serialization.Model): - """Classic Administrators. - - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type role: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'email_address': {'key': 'properties.emailAddress', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClassicAdministrator, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.email_address = kwargs.get('email_address', None) - self.role = kwargs.get('role', None) - - -class ClassicAdministratorListResult(msrest.serialization.Model): - """ClassicAdministrator list result information. - - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ClassicAdministrator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClassicAdministratorListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2015_06_01.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py index 9c121234dcd4..302c397c7bdf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/models/_models_py3.py @@ -15,16 +15,16 @@ class ClassicAdministrator(msrest.serialization.Model): """Classic Administrators. - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type role: str + :ivar id: The ID of the administrator. + :vartype id: str + :ivar name: The name of the administrator. + :vartype name: str + :ivar type: The type of the administrator. + :vartype type: str + :ivar email_address: The email address of the administrator. + :vartype email_address: str + :ivar role: The role of the administrator. + :vartype role: str """ _attribute_map = { @@ -45,6 +45,18 @@ def __init__( role: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the administrator. + :paramtype id: str + :keyword name: The name of the administrator. + :paramtype name: str + :keyword type: The type of the administrator. + :paramtype type: str + :keyword email_address: The email address of the administrator. + :paramtype email_address: str + :keyword role: The role of the administrator. + :paramtype role: str + """ super(ClassicAdministrator, self).__init__(**kwargs) self.id = id self.name = name @@ -56,10 +68,10 @@ def __init__( class ClassicAdministratorListResult(msrest.serialization.Model): """ClassicAdministrator list result information. - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of administrators. + :vartype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -74,6 +86,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of administrators. + :paramtype value: list[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministrator] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ClassicAdministratorListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -104,6 +122,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -147,6 +167,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -158,8 +180,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail """ _attribute_map = { @@ -172,5 +194,9 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2015_06_01.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py index d1a65c48396f..3f3b9fcbdd1a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_06_01/operations/_classic_administrators_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class ClassicAdministratorsOperations(object): """ClassicAdministratorsOperations operations. @@ -45,51 +79,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClassicAdministratorListResult"] + **kwargs: Any + ) -> Iterable["_models.ClassicAdministratorListResult"]: """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_06_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-06-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-06-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +133,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py index b40276826ca5..9496b373770e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_authorization_management_client.py @@ -6,98 +6,103 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations -from .operations import ProviderOperationsMetadataOperations -from .operations import GlobalAdministratorOperations -from .operations import RoleAssignmentsOperations -from .operations import ClassicAdministratorsOperations from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import ClassicAdministratorsOperations, GlobalAdministratorOperations, PermissionsOperations, ProviderOperationsMetadataOperations, RoleAssignmentsOperations, RoleDefinitionsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + definitions and role assignments. A role definition describes the set of actions that can be + performed on resources. A role assignment grants access to Azure Active Directory users. :ivar permissions: PermissionsOperations operations :vartype permissions: azure.mgmt.authorization.v2015_07_01.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: azure.mgmt.authorization.v2015_07_01.operations.RoleDefinitionsOperations + :vartype role_definitions: + azure.mgmt.authorization.v2015_07_01.operations.RoleDefinitionsOperations :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: azure.mgmt.authorization.v2015_07_01.operations.ProviderOperationsMetadataOperations + :vartype provider_operations_metadata: + azure.mgmt.authorization.v2015_07_01.operations.ProviderOperationsMetadataOperations :ivar global_administrator: GlobalAdministratorOperations operations - :vartype global_administrator: azure.mgmt.authorization.v2015_07_01.operations.GlobalAdministratorOperations + :vartype global_administrator: + azure.mgmt.authorization.v2015_07_01.operations.GlobalAdministratorOperations :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2015_07_01.operations.RoleAssignmentsOperations :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: azure.mgmt.authorization.v2015_07_01.operations.ClassicAdministratorsOperations + :vartype classic_administrators: + azure.mgmt.authorization.v2015_07_01.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_operations_metadata = ProviderOperationsMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.global_administrator = GlobalAdministratorOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.classic_administrators = ClassicAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py index 1f5e4f5da82c..a85c3a180b3c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-07-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json index 49f02d470747..9fb2ce46132b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "permissions": "PermissionsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py index 1061b48b1e9b..fe0b088b9686 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_authorization_management_client.py @@ -6,94 +6,103 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations -from .operations import ProviderOperationsMetadataOperations -from .operations import GlobalAdministratorOperations -from .operations import RoleAssignmentsOperations -from .operations import ClassicAdministratorsOperations from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import ClassicAdministratorsOperations, GlobalAdministratorOperations, PermissionsOperations, ProviderOperationsMetadataOperations, RoleAssignmentsOperations, RoleDefinitionsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role definitions and role assignments. A role definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + definitions and role assignments. A role definition describes the set of actions that can be + performed on resources. A role assignment grants access to Azure Active Directory users. :ivar permissions: PermissionsOperations operations :vartype permissions: azure.mgmt.authorization.v2015_07_01.aio.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: azure.mgmt.authorization.v2015_07_01.aio.operations.RoleDefinitionsOperations + :vartype role_definitions: + azure.mgmt.authorization.v2015_07_01.aio.operations.RoleDefinitionsOperations :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: azure.mgmt.authorization.v2015_07_01.aio.operations.ProviderOperationsMetadataOperations + :vartype provider_operations_metadata: + azure.mgmt.authorization.v2015_07_01.aio.operations.ProviderOperationsMetadataOperations :ivar global_administrator: GlobalAdministratorOperations operations - :vartype global_administrator: azure.mgmt.authorization.v2015_07_01.aio.operations.GlobalAdministratorOperations + :vartype global_administrator: + azure.mgmt.authorization.v2015_07_01.aio.operations.GlobalAdministratorOperations :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2015_07_01.aio.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2015_07_01.aio.operations.RoleAssignmentsOperations :ivar classic_administrators: ClassicAdministratorsOperations operations - :vartype classic_administrators: azure.mgmt.authorization.v2015_07_01.aio.operations.ClassicAdministratorsOperations + :vartype classic_administrators: + azure.mgmt.authorization.v2015_07_01.aio.operations.ClassicAdministratorsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.provider_operations_metadata = ProviderOperationsMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.global_administrator = GlobalAdministratorOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.classic_administrators = ClassicAdministratorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.global_administrator = GlobalAdministratorOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.classic_administrators = ClassicAdministratorsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py index a75a520500e4..0a9d7abc1609 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2015-07-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2015-07-01" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py index 32391e0679de..8d8f82f27f36 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_classic_administrators_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._classic_administrators_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,43 +52,44 @@ def list( """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,17 +98,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py index 058e29364251..d01a47f4ad0e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_global_administrator_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._global_administrator_operations import build_elevate_access_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,8 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def elevate_access( + @distributed_trace_async + async def elevate_access( # pylint: disable=inconsistent-return-statements self, **kwargs: Any ) -> None: @@ -56,30 +60,31 @@ async def elevate_access( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.elevate_access.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['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + + request = build_elevate_access_request( + api_version=api_version, + template_url=self.elevate_access.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - elevate_access.metadata = {'url': '/providers/Microsoft.Authorization/elevateAccess'} # type: ignore + elevate_access.metadata = {'url': "/providers/Microsoft.Authorization/elevateAccess"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py index b050a906cffc..576aadb5b89d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_permissions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -52,43 +56,44 @@ def list_for_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,21 +102,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -135,47 +146,52 @@ def list_for_resource( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,17 +200,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py index c8e7457bb267..a8855367bea9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_provider_operations_metadata_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._provider_operations_metadata_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -51,7 +56,7 @@ async def get( :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata, or the result of cls(response) @@ -63,33 +68,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -98,8 +99,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, expand: Optional[str] = "resourceTypes", @@ -107,44 +111,47 @@ def list( ) -> AsyncIterable["_models.ProviderOperationsMetadataListResult"]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -153,17 +160,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py index eb201def6556..c0d7c684b439 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -65,53 +70,59 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -147,49 +164,51 @@ def list_for_resource_group( :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,21 +217,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, @@ -235,32 +260,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -271,8 +293,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, @@ -289,8 +314,8 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters @@ -304,37 +329,33 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -343,8 +364,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -367,32 +391,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -401,8 +422,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, @@ -425,31 +449,28 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -460,8 +481,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_assignment_id: str, @@ -487,36 +511,32 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -525,8 +545,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_assignment_id: str, @@ -549,31 +572,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -582,8 +602,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -593,48 +616,49 @@ def list( :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -643,21 +667,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, @@ -670,48 +700,49 @@ def list_for_scope( :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -720,17 +751,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py index 1de28f66337e..2cb8d0a07e84 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/aio/operations/_role_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_definitions_operations import build_create_or_update_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,32 +68,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -99,8 +101,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -123,32 +128,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -157,8 +159,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -184,37 +189,33 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(role_definition, 'RoleDefinition') + + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -223,8 +224,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, scope: str, @@ -236,48 +240,49 @@ def list( :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -286,21 +291,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, role_definition_id: str, @@ -324,31 +335,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -357,4 +365,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleDefinitionId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleDefinitionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py index 0440ade890b1..a71e3bdf67b3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/__init__.py @@ -6,48 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ClassicAdministrator - from ._models_py3 import ClassicAdministratorListResult - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import Permission - from ._models_py3 import PermissionGetResult - from ._models_py3 import ProviderOperation - from ._models_py3 import ProviderOperationsMetadata - from ._models_py3 import ProviderOperationsMetadataListResult - from ._models_py3 import ResourceType - from ._models_py3 import RoleAssignment - from ._models_py3 import RoleAssignmentCreateParameters - from ._models_py3 import RoleAssignmentFilter - from ._models_py3 import RoleAssignmentListResult - from ._models_py3 import RoleAssignmentProperties - from ._models_py3 import RoleAssignmentPropertiesWithScope - from ._models_py3 import RoleDefinition - from ._models_py3 import RoleDefinitionFilter - from ._models_py3 import RoleDefinitionListResult -except (SyntaxError, ImportError): - from ._models import ClassicAdministrator # type: ignore - from ._models import ClassicAdministratorListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Permission # type: ignore - from ._models import PermissionGetResult # type: ignore - from ._models import ProviderOperation # type: ignore - from ._models import ProviderOperationsMetadata # type: ignore - from ._models import ProviderOperationsMetadataListResult # type: ignore - from ._models import ResourceType # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore - from ._models import RoleAssignmentProperties # type: ignore - from ._models import RoleAssignmentPropertiesWithScope # type: ignore - from ._models import RoleDefinition # type: ignore - from ._models import RoleDefinitionFilter # type: ignore - from ._models import RoleDefinitionListResult # type: ignore +from ._models_py3 import ClassicAdministrator +from ._models_py3 import ClassicAdministratorListResult +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Permission +from ._models_py3 import PermissionGetResult +from ._models_py3 import ProviderOperation +from ._models_py3 import ProviderOperationsMetadata +from ._models_py3 import ProviderOperationsMetadataListResult +from ._models_py3 import ResourceType +from ._models_py3 import RoleAssignment +from ._models_py3 import RoleAssignmentCreateParameters +from ._models_py3 import RoleAssignmentFilter +from ._models_py3 import RoleAssignmentListResult +from ._models_py3 import RoleAssignmentProperties +from ._models_py3 import RoleAssignmentPropertiesWithScope +from ._models_py3 import RoleDefinition +from ._models_py3 import RoleDefinitionFilter +from ._models_py3 import RoleDefinitionListResult + __all__ = [ 'ClassicAdministrator', diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py deleted file mode 100644 index b8bd200b487e..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models.py +++ /dev/null @@ -1,595 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ClassicAdministrator(msrest.serialization.Model): - """Classic Administrators. - - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type role: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'email_address': {'key': 'properties.emailAddress', 'type': 'str'}, - 'role': {'key': 'properties.role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClassicAdministrator, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.email_address = kwargs.get('email_address', None) - self.role = kwargs.get('role', None) - - -class ClassicAdministratorListResult(msrest.serialization.Model): - """ClassicAdministrator list result information. - - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ClassicAdministrator]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ClassicAdministratorListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2015_07_01.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Permission(msrest.serialization.Model): - """Role definition permissions. - - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - """ - - _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Permission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - - -class PermissionGetResult(msrest.serialization.Model): - """Permissions information. - - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Permission]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PermissionGetResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ProviderOperation(msrest.serialization.Model): - """Operation. - - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - - -class ProviderOperationsMetadata(msrest.serialization.Model): - """Provider Operations metadata. - - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] - :param operations: The provider operations. - :type operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ResourceType]'}, - 'operations': {'key': 'operations', 'type': '[ProviderOperation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationsMetadata, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.display_name = kwargs.get('display_name', None) - self.resource_types = kwargs.get('resource_types', None) - self.operations = kwargs.get('operations', None) - - -class ProviderOperationsMetadataListResult(msrest.serialization.Model): - """Provider operations metadata list. - - :param value: The list of providers. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderOperationsMetadata]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationsMetadataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceType(msrest.serialization.Model): - """Resource Type. - - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'operations': {'key': 'operations', 'type': '[ProviderOperation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceType, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.operations = kwargs.get('operations', None) - - -class RoleAssignment(msrest.serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :param properties: Role assignment properties. - :type properties: - ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'RoleAssignmentPropertiesWithScope'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs.get('properties', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param properties: Required. Role assignment properties. - :type properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties - """ - - _validation = { - 'properties': {'required': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RoleAssignmentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentProperties(msrest.serialization.Model): - """Role assignment properties. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - """ - - _validation = { - 'role_definition_id': {'required': True}, - 'principal_id': {'required': True}, - } - - _attribute_map = { - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentProperties, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - - -class RoleAssignmentPropertiesWithScope(msrest.serialization.Model): - """Role assignment properties with scope. - - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - """ - - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentPropertiesWithScope, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - - -class RoleDefinition(msrest.serialization.Model): - """Role definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar type: The role definition type. - :vartype type: str - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type assignable_scopes: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'role_type': {'key': 'properties.type', 'type': 'str'}, - 'permissions': {'key': 'properties.permissions', 'type': '[Permission]'}, - 'assignable_scopes': {'key': 'properties.assignableScopes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = kwargs.get('role_name', None) - self.description = kwargs.get('description', None) - self.role_type = kwargs.get('role_type', None) - self.permissions = kwargs.get('permissions', None) - self.assignable_scopes = kwargs.get('assignable_scopes', None) - - -class RoleDefinitionFilter(msrest.serialization.Model): - """Role Definitions filter. - - :param role_name: Returns role definition with the specific name. - :type role_name: str - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionFilter, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - - -class RoleDefinitionListResult(msrest.serialization.Model): - """Role definition list operation result. - - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py index bf01a81e0ea1..2ca2b4415349 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/models/_models_py3.py @@ -15,16 +15,16 @@ class ClassicAdministrator(msrest.serialization.Model): """Classic Administrators. - :param id: The ID of the administrator. - :type id: str - :param name: The name of the administrator. - :type name: str - :param type: The type of the administrator. - :type type: str - :param email_address: The email address of the administrator. - :type email_address: str - :param role: The role of the administrator. - :type role: str + :ivar id: The ID of the administrator. + :vartype id: str + :ivar name: The name of the administrator. + :vartype name: str + :ivar type: The type of the administrator. + :vartype type: str + :ivar email_address: The email address of the administrator. + :vartype email_address: str + :ivar role: The role of the administrator. + :vartype role: str """ _attribute_map = { @@ -45,6 +45,18 @@ def __init__( role: Optional[str] = None, **kwargs ): + """ + :keyword id: The ID of the administrator. + :paramtype id: str + :keyword name: The name of the administrator. + :paramtype name: str + :keyword type: The type of the administrator. + :paramtype type: str + :keyword email_address: The email address of the administrator. + :paramtype email_address: str + :keyword role: The role of the administrator. + :paramtype role: str + """ super(ClassicAdministrator, self).__init__(**kwargs) self.id = id self.name = name @@ -56,10 +68,10 @@ def __init__( class ClassicAdministratorListResult(msrest.serialization.Model): """ClassicAdministrator list result information. - :param value: An array of administrators. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of administrators. + :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -74,6 +86,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of administrators. + :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministrator] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ClassicAdministratorListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -104,6 +122,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -147,6 +167,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -158,8 +180,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail """ _attribute_map = { @@ -172,6 +194,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2015_07_01.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -179,10 +205,10 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] """ _attribute_map = { @@ -197,6 +223,12 @@ def __init__( not_actions: Optional[List[str]] = None, **kwargs ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + """ super(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -205,10 +237,10 @@ def __init__( class PermissionGetResult(msrest.serialization.Model): """Permissions information. - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of permissions. + :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -223,6 +255,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of permissions. + :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PermissionGetResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -231,16 +269,16 @@ def __init__( class ProviderOperation(msrest.serialization.Model): """Operation. - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any + :ivar name: The operation name. + :vartype name: str + :ivar display_name: The operation display name. + :vartype display_name: str + :ivar description: The operation description. + :vartype description: str + :ivar origin: The operation origin. + :vartype origin: str + :ivar properties: The operation properties. + :vartype properties: any """ _attribute_map = { @@ -261,6 +299,18 @@ def __init__( properties: Optional[Any] = None, **kwargs ): + """ + :keyword name: The operation name. + :paramtype name: str + :keyword display_name: The operation display name. + :paramtype display_name: str + :keyword description: The operation description. + :paramtype description: str + :keyword origin: The operation origin. + :paramtype origin: str + :keyword properties: The operation properties. + :paramtype properties: any + """ super(ProviderOperation, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -272,18 +322,18 @@ def __init__( class ProviderOperationsMetadata(msrest.serialization.Model): """Provider Operations metadata. - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] - :param operations: The provider operations. - :type operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] + :ivar id: The provider id. + :vartype id: str + :ivar name: The provider name. + :vartype name: str + :ivar type: The provider type. + :vartype type: str + :ivar display_name: The provider display name. + :vartype display_name: str + :ivar resource_types: The provider resource types. + :vartype resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] + :ivar operations: The provider operations. + :vartype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] """ _attribute_map = { @@ -306,6 +356,20 @@ def __init__( operations: Optional[List["ProviderOperation"]] = None, **kwargs ): + """ + :keyword id: The provider id. + :paramtype id: str + :keyword name: The provider name. + :paramtype name: str + :keyword type: The provider type. + :paramtype type: str + :keyword display_name: The provider display name. + :paramtype display_name: str + :keyword resource_types: The provider resource types. + :paramtype resource_types: list[~azure.mgmt.authorization.v2015_07_01.models.ResourceType] + :keyword operations: The provider operations. + :paramtype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] + """ super(ProviderOperationsMetadata, self).__init__(**kwargs) self.id = id self.name = name @@ -318,10 +382,10 @@ def __init__( class ProviderOperationsMetadataListResult(msrest.serialization.Model): """Provider operations metadata list. - :param value: The list of providers. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: The list of providers. + :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -336,6 +400,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of providers. + :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadata] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ProviderOperationsMetadataListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -344,12 +414,12 @@ def __init__( class ResourceType(msrest.serialization.Model): """Resource Type. - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] + :ivar name: The resource type name. + :vartype name: str + :ivar display_name: The resource type display name. + :vartype display_name: str + :ivar operations: The resource type operations. + :vartype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] """ _attribute_map = { @@ -366,6 +436,14 @@ def __init__( operations: Optional[List["ProviderOperation"]] = None, **kwargs ): + """ + :keyword name: The resource type name. + :paramtype name: str + :keyword display_name: The resource type display name. + :paramtype display_name: str + :keyword operations: The resource type operations. + :paramtype operations: list[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperation] + """ super(ResourceType, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -383,8 +461,8 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param properties: Role assignment properties. - :type properties: + :ivar properties: Role assignment properties. + :vartype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope """ @@ -407,6 +485,11 @@ def __init__( properties: Optional["RoleAssignmentPropertiesWithScope"] = None, **kwargs ): + """ + :keyword properties: Role assignment properties. + :paramtype properties: + ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentPropertiesWithScope + """ super(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -419,8 +502,8 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. Role assignment properties. - :type properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties + :ivar properties: Required. Role assignment properties. + :vartype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties """ _validation = { @@ -437,6 +520,10 @@ def __init__( properties: "RoleAssignmentProperties", **kwargs ): + """ + :keyword properties: Required. Role assignment properties. + :paramtype properties: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentProperties + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.properties = properties @@ -444,8 +531,8 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str """ _attribute_map = { @@ -458,6 +545,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id @@ -465,10 +556,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role assignment list. + :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -483,6 +574,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -493,11 +590,11 @@ class RoleAssignmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. The principal ID assigned to the role. This maps to the ID inside + the Active Directory. It can point to a user, service principal, or security group. + :vartype principal_id: str """ _validation = { @@ -517,6 +614,13 @@ def __init__( principal_id: str, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. The principal ID assigned to the role. This maps to the ID + inside the Active Directory. It can point to a user, service principal, or security group. + :paramtype principal_id: str + """ super(RoleAssignmentProperties, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -525,12 +629,12 @@ def __init__( class RoleAssignmentPropertiesWithScope(msrest.serialization.Model): """Role assignment properties with scope. - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str + :ivar scope: The role assignment scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str """ _attribute_map = { @@ -547,6 +651,14 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword scope: The role assignment scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + """ super(RoleAssignmentPropertiesWithScope, self).__init__(**kwargs) self.scope = scope self.role_definition_id = role_definition_id @@ -564,16 +676,16 @@ class RoleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The role definition type. :vartype type: str - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type assignable_scopes: list[str] + :ivar role_name: The role name. + :vartype role_name: str + :ivar description: The role definition description. + :vartype description: str + :ivar role_type: The role type. + :vartype role_type: str + :ivar permissions: Role definition permissions. + :vartype permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] + :ivar assignable_scopes: Role definition assignable scopes. + :vartype assignable_scopes: list[str] """ _validation = { @@ -603,6 +715,18 @@ def __init__( assignable_scopes: Optional[List[str]] = None, **kwargs ): + """ + :keyword role_name: The role name. + :paramtype role_name: str + :keyword description: The role definition description. + :paramtype description: str + :keyword role_type: The role type. + :paramtype role_type: str + :keyword permissions: Role definition permissions. + :paramtype permissions: list[~azure.mgmt.authorization.v2015_07_01.models.Permission] + :keyword assignable_scopes: Role definition assignable scopes. + :paramtype assignable_scopes: list[str] + """ super(RoleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -617,8 +741,8 @@ def __init__( class RoleDefinitionFilter(msrest.serialization.Model): """Role Definitions filter. - :param role_name: Returns role definition with the specific name. - :type role_name: str + :ivar role_name: Returns role definition with the specific name. + :vartype role_name: str """ _attribute_map = { @@ -631,6 +755,10 @@ def __init__( role_name: Optional[str] = None, **kwargs ): + """ + :keyword role_name: Returns role definition with the specific name. + :paramtype role_name: str + """ super(RoleDefinitionFilter, self).__init__(**kwargs) self.role_name = role_name @@ -638,10 +766,10 @@ def __init__( class RoleDefinitionListResult(msrest.serialization.Model): """Role definition list operation result. - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role definition list. + :vartype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -656,6 +784,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role definition list. + :paramtype value: list[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py index ff02d9d6c5f2..7f5aa56408a8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_classic_administrators_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,56 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class ClassicAdministratorsOperations(object): """ClassicAdministratorsOperations operations. @@ -45,51 +79,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ClassicAdministratorListResult"] + **kwargs: Any + ) -> Iterable["_models.ClassicAdministratorListResult"]: """Gets service administrator, account administrator, and co-administrators for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClassicAdministratorListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] + :return: An iterator like instance of either ClassicAdministratorListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ClassicAdministratorListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ClassicAdministratorListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ClassicAdministratorListResult', pipeline_response) + deserialized = self._deserialize("ClassicAdministratorListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,17 +133,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py index bb011b71baed..0aa8b4f4fb5e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_global_administrator_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_elevate_access_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/elevateAccess") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class GlobalAdministratorOperations(object): """GlobalAdministratorOperations operations. @@ -44,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def elevate_access( + @distributed_trace + def elevate_access( # pylint: disable=inconsistent-return-statements self, - **kwargs # type: Any - ): - # type: (...) -> None + **kwargs: Any + ) -> None: """Elevates access for a Global Administrator. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,30 +89,31 @@ def elevate_access( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.elevate_access.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['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + + request = build_elevate_access_request( + api_version=api_version, + template_url=self.elevate_access.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - elevate_access.metadata = {'url': '/providers/Microsoft.Authorization/elevateAccess'} # type: ignore + elevate_access.metadata = {'url': "/providers/Microsoft.Authorization/elevateAccess"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py index c5d6a3068837..564286fbf955 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_permissions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,100 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PermissionsOperations(object): """PermissionsOperations operations. @@ -45,55 +123,56 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PermissionGetResult"]: """Gets all permissions the caller has for 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 either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,31 +181,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.PermissionGetResult"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -141,47 +225,52 @@ def list_for_resource( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -190,17 +279,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py index 66d1bcd92e82..4db57feb10da 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_provider_operations_metadata_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_provider_namespace: str, + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}") + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/providerOperations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class ProviderOperationsMetadataOperations(object): """ProviderOperationsMetadataOperations operations. @@ -45,18 +113,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_provider_namespace, # type: str - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProviderOperationsMetadata" + resource_provider_namespace: str, + expand: Optional[str] = "resourceTypes", + **kwargs: Any + ) -> "_models.ProviderOperationsMetadata": """Gets provider operations metadata for the specified resource provider. :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata, or the result of cls(response) @@ -68,33 +136,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -103,54 +167,59 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProviderOperationsMetadataListResult"] + expand: Optional[str] = "resourceTypes", + **kwargs: Any + ) -> Iterable["_models.ProviderOperationsMetadataListResult"]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -159,17 +228,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py index 42f104b69284..ab1e44e3eb1d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,395 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,17 +418,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_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.RoleAssignmentListResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,53 +443,59 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,77 +504,84 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_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), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,28 +590,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. @@ -242,32 +633,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -278,16 +666,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -297,8 +687,8 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. :type parameters: ~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentCreateParameters @@ -312,37 +702,33 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -351,15 +737,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> "_models.RoleAssignment": """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -376,32 +764,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -410,14 +795,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_assignment_id: str, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Deletes a role assignment. :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, @@ -435,31 +822,28 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -470,15 +854,17 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_assignment_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_assignment_id: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, @@ -498,36 +884,32 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -536,14 +918,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_assignment_id: str, + **kwargs: Any + ) -> "_models.RoleAssignment": """Gets a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment, including the scope, @@ -561,31 +945,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -594,60 +975,63 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -656,76 +1040,82 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -734,17 +1124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py index be3d299fb60a..8d3e95925fbb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2015_07_01/operations/_role_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,203 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + scope: str, + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + scope: str, + role_definition_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleDefinitionId}") + path_format_arguments = { + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleDefinitionsOperations(object): """RoleDefinitionsOperations operations. @@ -45,13 +226,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleDefinition"] + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> Optional["_models.RoleDefinition"]: """Deletes a role definition. :param scope: The scope of the role definition. @@ -68,32 +249,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -104,15 +282,17 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> "_models.RoleDefinition": """Get role definition by name (GUID). :param scope: The scope of the role definition. @@ -129,32 +309,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -163,16 +340,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def create_or_update( self, - scope, # type: str - role_definition_id, # type: str - role_definition, # type: "_models.RoleDefinition" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + role_definition: "_models.RoleDefinition", + **kwargs: Any + ) -> "_models.RoleDefinition": """Creates or updates a role definition. :param scope: The scope of the role definition. @@ -191,37 +370,33 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(role_definition, 'RoleDefinition') + + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -230,62 +405,65 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleDefinitionListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleDefinitionListResult"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2015_07_01.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2015-07-01") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -294,27 +472,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + role_definition_id: str, + **kwargs: Any + ) -> "_models.RoleDefinition": """Gets a role definition by ID. :param role_definition_id: The fully qualified role definition ID. Use the format, @@ -333,31 +516,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleDefinitionId': self._serialize.url("role_definition_id", role_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') + api_version = kwargs.pop('api_version', "2015-07-01") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -366,4 +546,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleDefinitionId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleDefinitionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py index 4441499e6885..7b9d96208098 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_authorization_management_client.py @@ -6,88 +6,94 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ProviderOperationsMetadataOperations -from .operations import RoleAssignmentsOperations -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import PermissionsOperations, ProviderOperationsMetadataOperations, RoleAssignmentsOperations, RoleDefinitionsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These calls handle provider operations. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These calls handle provider operations. :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: azure.mgmt.authorization.v2018_01_01_preview.operations.ProviderOperationsMetadataOperations + :vartype provider_operations_metadata: + azure.mgmt.authorization.v2018_01_01_preview.operations.ProviderOperationsMetadataOperations :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2018_01_01_preview.operations.RoleAssignmentsOperations :ivar permissions: PermissionsOperations operations - :vartype permissions: azure.mgmt.authorization.v2018_01_01_preview.operations.PermissionsOperations + :vartype permissions: + azure.mgmt.authorization.v2018_01_01_preview.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations + :vartype role_definitions: + azure.mgmt.authorization.v2018_01_01_preview.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.provider_operations_metadata = ProviderOperationsMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py index 73fe3723d364..5be8a6160a6a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json index 9d42dccaf7c2..9ac482fac2ee 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These calls handle provider operations.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "provider_operations_metadata": "ProviderOperationsMetadataOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py index d22ed81ce409..c83135330e0b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_authorization_management_client.py @@ -6,84 +6,94 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import ProviderOperationsMetadataOperations -from .operations import RoleAssignmentsOperations -from .operations import PermissionsOperations -from .operations import RoleDefinitionsOperations from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import PermissionsOperations, ProviderOperationsMetadataOperations, RoleAssignmentsOperations, RoleDefinitionsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These calls handle provider operations. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These calls handle provider operations. :ivar provider_operations_metadata: ProviderOperationsMetadataOperations operations - :vartype provider_operations_metadata: azure.mgmt.authorization.v2018_01_01_preview.aio.operations.ProviderOperationsMetadataOperations + :vartype provider_operations_metadata: + azure.mgmt.authorization.v2018_01_01_preview.aio.operations.ProviderOperationsMetadataOperations :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleAssignmentsOperations :ivar permissions: PermissionsOperations operations - :vartype permissions: azure.mgmt.authorization.v2018_01_01_preview.aio.operations.PermissionsOperations + :vartype permissions: + azure.mgmt.authorization.v2018_01_01_preview.aio.operations.PermissionsOperations :ivar role_definitions: RoleDefinitionsOperations operations - :vartype role_definitions: azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleDefinitionsOperations + :vartype role_definitions: + azure.mgmt.authorization.v2018_01_01_preview.aio.operations.RoleDefinitionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.provider_operations_metadata = ProviderOperationsMetadataOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.permissions = PermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_definitions = RoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.provider_operations_metadata = ProviderOperationsMetadataOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.permissions = PermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_definitions = RoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py index d32ebcc2d62f..6053946c363d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py index 0af7174cf8d9..ef125e33076f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_permissions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._permissions_operations import build_list_for_resource_group_request, build_list_for_resource_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -52,43 +56,44 @@ def list_for_resource_group( :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,21 +102,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -135,47 +146,52 @@ def list_for_resource( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,17 +200,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py index 6c6e26e27bb6..80f50ec639c5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_provider_operations_metadata_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._provider_operations_metadata_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_provider_namespace: str, @@ -51,7 +56,7 @@ async def get( :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata, or the result of cls(response) @@ -63,33 +68,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - } - url = self._client.format_url(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 expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -98,8 +99,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, expand: Optional[str] = "resourceTypes", @@ -107,44 +111,47 @@ def list( ) -> AsyncIterable["_models.ProviderOperationsMetadataListResult"]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -153,17 +160,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py index 776614cc3902..b018c460b50c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -65,53 +70,59 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -147,49 +164,51 @@ def list_for_resource_group( :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,21 +217,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, @@ -235,32 +260,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -271,8 +293,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, @@ -289,11 +314,12 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment @@ -304,37 +330,33 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -343,8 +365,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -367,32 +392,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -401,8 +423,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_id: str, @@ -422,31 +447,28 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -457,8 +479,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_id: str, @@ -470,7 +495,8 @@ async def create_by_id( :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment @@ -481,36 +507,32 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -519,8 +541,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -540,31 +565,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -573,8 +595,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -584,48 +609,49 @@ def list( :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -634,21 +660,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, @@ -661,48 +693,49 @@ def list_for_scope( :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -711,17 +744,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py index e280640ef01d..f2451d0f5adf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/aio/operations/_role_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_definitions_operations import build_create_or_update_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def delete( self, scope: str, @@ -63,32 +68,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -99,8 +101,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -123,32 +128,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -157,8 +159,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace_async async def create_or_update( self, scope: str, @@ -184,37 +189,33 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(role_definition, 'RoleDefinition') + + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -223,8 +224,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, scope: str, @@ -236,48 +240,49 @@ def list( :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -286,21 +291,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -324,31 +335,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -357,4 +365,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py index 28a31e633985..ec95a80e25b4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/__init__.py @@ -6,40 +6,23 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import Permission - from ._models_py3 import PermissionGetResult - from ._models_py3 import ProviderOperation - from ._models_py3 import ProviderOperationsMetadata - from ._models_py3 import ProviderOperationsMetadataListResult - from ._models_py3 import ResourceType - from ._models_py3 import RoleAssignment - from ._models_py3 import RoleAssignmentCreateParameters - from ._models_py3 import RoleAssignmentFilter - from ._models_py3 import RoleAssignmentListResult - from ._models_py3 import RoleDefinition - from ._models_py3 import RoleDefinitionFilter - from ._models_py3 import RoleDefinitionListResult -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Permission # type: ignore - from ._models import PermissionGetResult # type: ignore - from ._models import ProviderOperation # type: ignore - from ._models import ProviderOperationsMetadata # type: ignore - from ._models import ProviderOperationsMetadataListResult # type: ignore - from ._models import ResourceType # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore - from ._models import RoleDefinition # type: ignore - from ._models import RoleDefinitionFilter # type: ignore - from ._models import RoleDefinitionListResult # type: ignore +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Permission +from ._models_py3 import PermissionGetResult +from ._models_py3 import ProviderOperation +from ._models_py3 import ProviderOperationsMetadata +from ._models_py3 import ProviderOperationsMetadataListResult +from ._models_py3 import ResourceType +from ._models_py3 import RoleAssignment +from ._models_py3 import RoleAssignmentCreateParameters +from ._models_py3 import RoleAssignmentFilter +from ._models_py3 import RoleAssignmentListResult +from ._models_py3 import RoleDefinition +from ._models_py3 import RoleDefinitionFilter +from ._models_py3 import RoleDefinitionListResult + __all__ = [ 'ErrorAdditionalInfo', diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py deleted file mode 100644 index b85e6f7ca84d..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models.py +++ /dev/null @@ -1,521 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Permission(msrest.serialization.Model): - """Role definition permissions. - - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] - """ - - _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - 'data_actions': {'key': 'dataActions', 'type': '[str]'}, - 'not_data_actions': {'key': 'notDataActions', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Permission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - self.data_actions = kwargs.get('data_actions', None) - self.not_data_actions = kwargs.get('not_data_actions', None) - - -class PermissionGetResult(msrest.serialization.Model): - """Permissions information. - - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Permission]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PermissionGetResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ProviderOperation(msrest.serialization.Model): - """Operation. - - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - :param is_data_action: The dataAction flag to specify the operation type. - :type is_data_action: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - self.is_data_action = kwargs.get('is_data_action', None) - - -class ProviderOperationsMetadata(msrest.serialization.Model): - """Provider Operations metadata. - - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] - :param operations: The provider operations. - :type operations: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'resource_types': {'key': 'resourceTypes', 'type': '[ResourceType]'}, - 'operations': {'key': 'operations', 'type': '[ProviderOperation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationsMetadata, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.display_name = kwargs.get('display_name', None) - self.resource_types = kwargs.get('resource_types', None) - self.operations = kwargs.get('operations', None) - - -class ProviderOperationsMetadataListResult(msrest.serialization.Model): - """Provider operations metadata list. - - :param value: The list of providers. - :type value: - list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderOperationsMetadata]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderOperationsMetadataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class ResourceType(msrest.serialization.Model): - """Resource Type. - - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type operations: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'operations': {'key': 'operations', 'type': '[ProviderOperation]'}, - } - - def __init__( - self, - **kwargs - ): - super(ResourceType, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - self.operations = kwargs.get('operations', None) - - -class RoleAssignment(msrest.serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'can_delegate': {'key': 'properties.canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool - """ - - _validation = { - 'role_definition_id': {'required': True}, - 'principal_id': {'required': True}, - } - - _attribute_map = { - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'can_delegate': {'key': 'properties.canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'can_delegate': {'key': 'canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleDefinition(msrest.serialization.Model): - """Role definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role definition ID. - :vartype id: str - :ivar name: The role definition name. - :vartype name: str - :ivar type: The role definition type. - :vartype type: str - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type assignable_scopes: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'role_type': {'key': 'properties.type', 'type': 'str'}, - 'permissions': {'key': 'properties.permissions', 'type': '[Permission]'}, - 'assignable_scopes': {'key': 'properties.assignableScopes', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.role_name = kwargs.get('role_name', None) - self.description = kwargs.get('description', None) - self.role_type = kwargs.get('role_type', None) - self.permissions = kwargs.get('permissions', None) - self.assignable_scopes = kwargs.get('assignable_scopes', None) - - -class RoleDefinitionFilter(msrest.serialization.Model): - """Role Definitions filter. - - :param role_name: Returns role definition with the specific name. - :type role_name: str - :param type: Returns role definition with the specific type. - :type type: str - """ - - _attribute_map = { - 'role_name': {'key': 'roleName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionFilter, self).__init__(**kwargs) - self.role_name = kwargs.get('role_name', None) - self.type = kwargs.get('type', None) - - -class RoleDefinitionListResult(msrest.serialization.Model): - """Role definition list operation result. - - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py index 86a699aa985f..19e9f8ca898d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/models/_models_py3.py @@ -37,6 +37,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -80,6 +82,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -91,8 +95,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail """ _attribute_map = { @@ -105,6 +109,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2018_01_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -112,14 +120,14 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] """ _attribute_map = { @@ -138,6 +146,16 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + :keyword data_actions: Allowed Data actions. + :paramtype data_actions: list[str] + :keyword not_data_actions: Denied Data actions. + :paramtype not_data_actions: list[str] + """ super(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -148,10 +166,10 @@ def __init__( class PermissionGetResult(msrest.serialization.Model): """Permissions information. - :param value: An array of permissions. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: An array of permissions. + :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -166,6 +184,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: An array of permissions. + :paramtype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(PermissionGetResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -174,18 +198,18 @@ def __init__( class ProviderOperation(msrest.serialization.Model): """Operation. - :param name: The operation name. - :type name: str - :param display_name: The operation display name. - :type display_name: str - :param description: The operation description. - :type description: str - :param origin: The operation origin. - :type origin: str - :param properties: The operation properties. - :type properties: any - :param is_data_action: The dataAction flag to specify the operation type. - :type is_data_action: bool + :ivar name: The operation name. + :vartype name: str + :ivar display_name: The operation display name. + :vartype display_name: str + :ivar description: The operation description. + :vartype description: str + :ivar origin: The operation origin. + :vartype origin: str + :ivar properties: The operation properties. + :vartype properties: any + :ivar is_data_action: The dataAction flag to specify the operation type. + :vartype is_data_action: bool """ _attribute_map = { @@ -208,6 +232,20 @@ def __init__( is_data_action: Optional[bool] = None, **kwargs ): + """ + :keyword name: The operation name. + :paramtype name: str + :keyword display_name: The operation display name. + :paramtype display_name: str + :keyword description: The operation description. + :paramtype description: str + :keyword origin: The operation origin. + :paramtype origin: str + :keyword properties: The operation properties. + :paramtype properties: any + :keyword is_data_action: The dataAction flag to specify the operation type. + :paramtype is_data_action: bool + """ super(ProviderOperation, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -220,18 +258,20 @@ def __init__( class ProviderOperationsMetadata(msrest.serialization.Model): """Provider Operations metadata. - :param id: The provider id. - :type id: str - :param name: The provider name. - :type name: str - :param type: The provider type. - :type type: str - :param display_name: The provider display name. - :type display_name: str - :param resource_types: The provider resource types. - :type resource_types: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] - :param operations: The provider operations. - :type operations: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] + :ivar id: The provider id. + :vartype id: str + :ivar name: The provider name. + :vartype name: str + :ivar type: The provider type. + :vartype type: str + :ivar display_name: The provider display name. + :vartype display_name: str + :ivar resource_types: The provider resource types. + :vartype resource_types: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] + :ivar operations: The provider operations. + :vartype operations: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] """ _attribute_map = { @@ -254,6 +294,22 @@ def __init__( operations: Optional[List["ProviderOperation"]] = None, **kwargs ): + """ + :keyword id: The provider id. + :paramtype id: str + :keyword name: The provider name. + :paramtype name: str + :keyword type: The provider type. + :paramtype type: str + :keyword display_name: The provider display name. + :paramtype display_name: str + :keyword resource_types: The provider resource types. + :paramtype resource_types: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ResourceType] + :keyword operations: The provider operations. + :paramtype operations: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] + """ super(ProviderOperationsMetadata, self).__init__(**kwargs) self.id = id self.name = name @@ -266,11 +322,11 @@ def __init__( class ProviderOperationsMetadataListResult(msrest.serialization.Model): """Provider operations metadata list. - :param value: The list of providers. - :type value: + :ivar value: The list of providers. + :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -285,6 +341,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of providers. + :paramtype value: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadata] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(ProviderOperationsMetadataListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -293,12 +356,13 @@ def __init__( class ResourceType(msrest.serialization.Model): """Resource Type. - :param name: The resource type name. - :type name: str - :param display_name: The resource type display name. - :type display_name: str - :param operations: The resource type operations. - :type operations: list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] + :ivar name: The resource type name. + :vartype name: str + :ivar display_name: The resource type display name. + :vartype display_name: str + :ivar operations: The resource type operations. + :vartype operations: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] """ _attribute_map = { @@ -315,6 +379,15 @@ def __init__( operations: Optional[List["ProviderOperation"]] = None, **kwargs ): + """ + :keyword name: The resource type name. + :paramtype name: str + :keyword display_name: The resource type display name. + :paramtype display_name: str + :keyword operations: The resource type operations. + :paramtype operations: + list[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperation] + """ super(ResourceType, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -332,14 +405,14 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :ivar scope: The role assignment scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar can_delegate: The Delegation flag for the role assignment. + :vartype can_delegate: bool """ _validation = { @@ -367,6 +440,16 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword scope: The role assignment scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword can_delegate: The Delegation flag for the role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -382,13 +465,13 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. The principal ID assigned to the role. This maps to the ID inside + the Active Directory. It can point to a user, service principal, or security group. + :vartype principal_id: str + :ivar can_delegate: The delegation flag used for creating a role assignment. + :vartype can_delegate: bool """ _validation = { @@ -410,6 +493,15 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. The principal ID assigned to the role. This maps to the ID + inside the Active Directory. It can point to a user, service principal, or security group. + :paramtype principal_id: str + :keyword can_delegate: The delegation flag used for creating a role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -419,10 +511,10 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str + :ivar can_delegate: The Delegation flag for the role assignment. + :vartype can_delegate: bool """ _attribute_map = { @@ -437,6 +529,12 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + :keyword can_delegate: The Delegation flag for the role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate @@ -445,10 +543,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role assignment list. + :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -463,6 +561,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -479,16 +583,16 @@ class RoleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The role definition type. :vartype type: str - :param role_name: The role name. - :type role_name: str - :param description: The role definition description. - :type description: str - :param role_type: The role type. - :type role_type: str - :param permissions: Role definition permissions. - :type permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] - :param assignable_scopes: Role definition assignable scopes. - :type assignable_scopes: list[str] + :ivar role_name: The role name. + :vartype role_name: str + :ivar description: The role definition description. + :vartype description: str + :ivar role_type: The role type. + :vartype role_type: str + :ivar permissions: Role definition permissions. + :vartype permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] + :ivar assignable_scopes: Role definition assignable scopes. + :vartype assignable_scopes: list[str] """ _validation = { @@ -518,6 +622,18 @@ def __init__( assignable_scopes: Optional[List[str]] = None, **kwargs ): + """ + :keyword role_name: The role name. + :paramtype role_name: str + :keyword description: The role definition description. + :paramtype description: str + :keyword role_type: The role type. + :paramtype role_type: str + :keyword permissions: Role definition permissions. + :paramtype permissions: list[~azure.mgmt.authorization.v2018_01_01_preview.models.Permission] + :keyword assignable_scopes: Role definition assignable scopes. + :paramtype assignable_scopes: list[str] + """ super(RoleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -532,10 +648,10 @@ def __init__( class RoleDefinitionFilter(msrest.serialization.Model): """Role Definitions filter. - :param role_name: Returns role definition with the specific name. - :type role_name: str - :param type: Returns role definition with the specific type. - :type type: str + :ivar role_name: Returns role definition with the specific name. + :vartype role_name: str + :ivar type: Returns role definition with the specific type. + :vartype type: str """ _attribute_map = { @@ -550,6 +666,12 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword role_name: Returns role definition with the specific name. + :paramtype role_name: str + :keyword type: Returns role definition with the specific type. + :paramtype type: str + """ super(RoleDefinitionFilter, self).__init__(**kwargs) self.role_name = role_name self.type = type @@ -558,10 +680,10 @@ def __init__( class RoleDefinitionListResult(msrest.serialization.Model): """Role definition list operation result. - :param value: Role definition list. - :type value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role definition list. + :vartype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -576,6 +698,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role definition list. + :paramtype value: list[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py index 5fcce526eb28..9a79337bcd38 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_permissions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,100 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class PermissionsOperations(object): """PermissionsOperations operations. @@ -45,55 +123,56 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.PermissionGetResult"]: """Gets all permissions the caller has for 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 either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,31 +181,36 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions"} # type: ignore + @distributed_trace def list_for_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 - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.PermissionGetResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.PermissionGetResult"]: """Gets all permissions the caller has for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -141,47 +225,52 @@ def list_for_resource( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PermissionGetResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.PermissionGetResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.PermissionGetResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('PermissionGetResult', pipeline_response) + deserialized = self._deserialize("PermissionGetResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -190,17 +279,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py index 2331c9c04547..93ba5981fa24 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_provider_operations_metadata_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_provider_namespace: str, + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}") + path_format_arguments = { + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + *, + expand: Optional[str] = "resourceTypes", + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/providerOperations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class ProviderOperationsMetadataOperations(object): """ProviderOperationsMetadataOperations operations. @@ -45,18 +113,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_provider_namespace, # type: str - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.ProviderOperationsMetadata" + resource_provider_namespace: str, + expand: Optional[str] = "resourceTypes", + **kwargs: Any + ) -> "_models.ProviderOperationsMetadata": """Gets provider operations metadata for the specified resource provider. :param resource_provider_namespace: The namespace of the resource provider. :type resource_provider_namespace: str - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ProviderOperationsMetadata, or the result of cls(response) @@ -68,33 +136,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_provider_namespace=resource_provider_namespace, + api_version=api_version, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ProviderOperationsMetadata', pipeline_response) @@ -103,54 +167,59 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}'} # type: ignore + get.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}"} # type: ignore + + + @distributed_trace def list( self, - expand="resourceTypes", # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProviderOperationsMetadataListResult"] + expand: Optional[str] = "resourceTypes", + **kwargs: Any + ) -> Iterable["_models.ProviderOperationsMetadataListResult"]: """Gets provider operations metadata for all resource providers. - :param expand: Specifies whether to expand the values. + :param expand: Specifies whether to expand the values. Default value is "resourceTypes". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] + :return: An iterator like instance of either ProviderOperationsMetadataListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.ProviderOperationsMetadataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderOperationsMetadataListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProviderOperationsMetadataListResult', pipeline_response) + deserialized = self._deserialize("ProviderOperationsMetadataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -159,17 +228,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/providerOperations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/providerOperations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py index 8ec1f2daa997..86c8573f641c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,395 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,17 +418,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_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.RoleAssignmentListResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,53 +443,59 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,77 +504,84 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,28 +590,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. @@ -242,32 +633,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -278,16 +666,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -297,11 +687,12 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment @@ -312,37 +703,33 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -351,15 +738,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> "_models.RoleAssignment": """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -376,32 +765,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -410,14 +796,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_id: str, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. @@ -432,31 +820,28 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -467,21 +852,24 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignment @@ -492,36 +880,32 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -530,14 +914,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + **kwargs: Any + ) -> "_models.RoleAssignment": """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. @@ -552,31 +938,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -585,60 +968,63 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,76 +1033,82 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -725,17 +1117,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py index 00fc742eda70..2886d09c2136 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_01_01_preview/operations/_role_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,203 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_delete_request( + scope: str, + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + scope: str, + role_definition_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleDefinitionId": _SERIALIZER.url("role_definition_id", role_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleDefinitions") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleDefinitionsOperations(object): """RoleDefinitionsOperations operations. @@ -45,13 +226,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleDefinition"] + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> Optional["_models.RoleDefinition"]: """Deletes a role definition. :param scope: The scope of the role definition. @@ -68,32 +249,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -104,15 +282,17 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + **kwargs: Any + ) -> "_models.RoleDefinition": """Get role definition by name (GUID). :param scope: The scope of the role definition. @@ -129,32 +309,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -163,16 +340,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def create_or_update( self, - scope, # type: str - role_definition_id, # type: str - role_definition, # type: "_models.RoleDefinition" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + scope: str, + role_definition_id: str, + role_definition: "_models.RoleDefinition", + **kwargs: Any + ) -> "_models.RoleDefinition": """Creates or updates a role definition. :param scope: The scope of the role definition. @@ -191,37 +370,33 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleDefinitionId': self._serialize.url("role_definition_id", role_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(role_definition, 'RoleDefinition') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(role_definition, 'RoleDefinition') + + request = build_create_or_update_request( + scope=scope, + role_definition_id=role_definition_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -230,62 +405,65 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}'} # type: ignore + create_or_update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}"} # type: ignore + + + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleDefinitionListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleDefinitionListResult"]: """Get all role definitions that are applicable at scope and above. :param scope: The scope of the role definition. :type scope: str :param filter: The filter to apply on the operation. Use atScopeAndBelow filter to search below - the given scope as well. + the given scope as well. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] + :return: An iterator like instance of either RoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_01_01_preview.models.RoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("RoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -294,27 +472,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleDefinitions'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleDefinition" + role_id: str, + **kwargs: Any + ) -> "_models.RoleDefinition": """Gets a role definition by ID. :param role_id: The fully qualified role definition ID. Use the format, @@ -333,31 +516,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') + api_version = kwargs.pop('api_version', "2018-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleDefinition', pipeline_response) @@ -366,4 +546,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py index ce546ece5311..3923119dd3c7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_authorization_management_client.py @@ -6,113 +6,115 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import AccessReviewDefaultSettingsOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Access reviews service provides the workflow for running access reviews on different kind of + resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2018_05_01_preview.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsOperations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesOperations + :vartype access_review_instances: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceOperations + :vartype access_review_instance: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceDecisionsOperations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :vartype access_review_default_settings: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceMyDecisionsOperations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.v2018_05_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances = AccessReviewInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance = AccessReviewInstanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py index 5c9bd6311f43..7462e20ce1ec 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-05-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json index e992c72e1e2d..a3bd4454d665 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py index 57640f36f638..58171cb14966 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_authorization_management_client.py @@ -6,109 +6,115 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import AccessReviewDefaultSettingsOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Access reviews service provides the workflow for running access reviews on different kind of + resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesOperations + :vartype access_review_instances: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceOperations + :vartype access_review_instance: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :vartype access_review_default_settings: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.v2018_05_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances = AccessReviewInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance = AccessReviewInstanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py index a07795ddc22a..b79d4cf39636 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-05-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-05-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py index 13b6cb88ffe8..fab757b4ba78 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, **kwargs: Any @@ -56,31 +60,28 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -89,8 +90,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace_async async def put( self, properties: "_models.AccessReviewScheduleSettings", @@ -99,7 +103,8 @@ async def put( """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings @@ -110,36 +115,32 @@ async def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -148,4 +149,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py index e1a995a343de..4fccc667bddf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instance_decisions_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -54,45 +58,48 @@ def list( :param id: The id of the access review instance. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +108,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index 22ab8981dbfd..5b785907036c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instance_my_decisions_operations import build_get_by_id_request, build_list_request, build_patch_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -54,44 +59,46 @@ def list( :param id: The id of the access review instance. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,21 +107,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -140,33 +153,30 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -175,8 +185,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace_async async def patch( self, schedule_definition_id: str, @@ -194,7 +207,8 @@ async def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision @@ -205,38 +219,34 @@ async def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -245,4 +255,6 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py index 75c39ff8437c..5fd7527a290b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instance_operations import build_accept_recommendations_request, build_apply_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,8 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def stop( + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -62,41 +66,40 @@ async def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + - async def reset_decisions( + @distributed_trace_async + async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -118,41 +121,40 @@ async def reset_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + - async def apply_decisions( + @distributed_trace_async + async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -174,41 +176,40 @@ async def apply_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + - async def send_reminders( + @distributed_trace_async + async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -230,41 +231,40 @@ async def send_reminders( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore - async def accept_recommendations( + + @distributed_trace_async + async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -286,35 +286,33 @@ async def accept_recommendations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - accept_recommendations.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index fc9106f368c8..1bfd673bec23 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instances_assigned_for_my_approval_operations import build_get_by_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -51,43 +56,44 @@ def list( :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -96,21 +102,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -133,32 +145,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -167,4 +176,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py index 479d93c18f55..174521ecfdd8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instances_operations import build_get_by_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -51,44 +56,46 @@ def list( :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,21 +104,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -134,33 +147,30 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -169,4 +179,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 7d876ea7ecd4..cd469badd611 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,39 +52,42 @@ def list( """Get access review instances assigned for my approval. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +96,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index ede53b7fea6d..312d1c67b3fe 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_schedule_definitions_operations import build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -48,43 +53,44 @@ def list( """Get access review schedule definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,21 +99,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -127,32 +139,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -161,9 +170,12 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -182,39 +194,38 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, @@ -226,7 +237,8 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition @@ -237,37 +249,33 @@ async def create_or_update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -276,9 +284,12 @@ async def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -297,35 +308,33 @@ async def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py index 1e2b098f9c7f..fe12f1932998 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py index 498d27291a3b..d4fb08e9d3be 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/__init__.py @@ -6,46 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessReviewDecision - from ._models_py3 import AccessReviewDecisionListResult - from ._models_py3 import AccessReviewDecisionProperties - from ._models_py3 import AccessReviewDecisionTarget - from ._models_py3 import AccessReviewDefaultSettings - from ._models_py3 import AccessReviewInstance - from ._models_py3 import AccessReviewInstanceListResult - from ._models_py3 import AccessReviewReviewer - from ._models_py3 import AccessReviewScheduleDefinition - from ._models_py3 import AccessReviewScheduleDefinitionListResult - from ._models_py3 import AccessReviewScheduleDefinitionProperties - from ._models_py3 import AccessReviewScheduleSettings - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorDefinitionProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import ServicePrincipalDecisionTarget - from ._models_py3 import UserDecisionTarget -except (SyntaxError, ImportError): - from ._models import AccessReviewDecision # type: ignore - from ._models import AccessReviewDecisionListResult # type: ignore - from ._models import AccessReviewDecisionProperties # type: ignore - from ._models import AccessReviewDecisionTarget # type: ignore - from ._models import AccessReviewDefaultSettings # type: ignore - from ._models import AccessReviewInstance # type: ignore - from ._models import AccessReviewInstanceListResult # type: ignore - from ._models import AccessReviewReviewer # type: ignore - from ._models import AccessReviewScheduleDefinition # type: ignore - from ._models import AccessReviewScheduleDefinitionListResult # type: ignore - from ._models import AccessReviewScheduleDefinitionProperties # type: ignore - from ._models import AccessReviewScheduleSettings # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import ServicePrincipalDecisionTarget # type: ignore - from ._models import UserDecisionTarget # type: ignore +from ._models_py3 import AccessReviewDecision +from ._models_py3 import AccessReviewDecisionListResult +from ._models_py3 import AccessReviewDecisionProperties +from ._models_py3 import AccessReviewDecisionTarget +from ._models_py3 import AccessReviewDefaultSettings +from ._models_py3 import AccessReviewInstance +from ._models_py3 import AccessReviewInstanceListResult +from ._models_py3 import AccessReviewReviewer +from ._models_py3 import AccessReviewScheduleDefinition +from ._models_py3 import AccessReviewScheduleDefinitionListResult +from ._models_py3 import AccessReviewScheduleDefinitionProperties +from ._models_py3 import AccessReviewScheduleSettings +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDefinitionProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ServicePrincipalDecisionTarget +from ._models_py3 import UserDecisionTarget + from ._authorization_management_client_enums import ( AccessRecommendationType, diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py index d00c500e2fa7..034e4a3e0de8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_authorization_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRecommendationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The feature- generated recommendation shown to the reviewer. """ @@ -34,14 +19,14 @@ class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu DENY = "Deny" NO_INFO_AVAILABLE = "NoInfoAvailable" -class AccessReviewActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewApplyResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The outcome of applying the decision. """ @@ -52,7 +37,7 @@ class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" APPLY_NOT_SUPPORTED = "ApplyNotSupported" -class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewInstanceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an access review instance. """ @@ -68,14 +53,14 @@ class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, E AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewRecurrencePatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrencePatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence type : weekly, monthly, etc. """ WEEKLY = "weekly" ABSOLUTE_MONTHLY = "absoluteMonthly" -class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrenceRangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence range type. The possible values are: endDate, noEnd, numbered. """ @@ -83,7 +68,7 @@ class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, s NO_END = "noEnd" NUMBERED = "numbered" -class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny """ @@ -94,14 +79,14 @@ class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DONT_KNOW = "DontKnow" NOT_NOTIFIED = "NotNotified" -class AccessReviewReviewerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewReviewerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. @@ -111,7 +96,7 @@ class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiv SELF = "Self" MANAGERS = "Managers" -class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an accessReview. """ @@ -127,21 +112,21 @@ class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMe AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type user/servicePrincipal to review """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DecisionTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of decision target : User/ServicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DefaultDecisionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultDecisionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This specifies the behavior for the autoReview feature when an access review completes. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py deleted file mode 100644 index a722a5bff820..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models.py +++ /dev/null @@ -1,1204 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessReviewDecision(msrest.serialization.Model): - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review decision id. - :vartype id: str - :ivar name: The access review decision name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_properties_applied_by_principal_id: The identity id. - :vartype principal_id_properties_applied_by_principal_id: str - :ivar principal_type_properties_applied_by_principal_type: The identity type : - user/servicePrincipal. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_applied_by_principal_name: The identity display name. - :vartype principal_name_properties_applied_by_principal_name: str - :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if - valid). - :vartype user_principal_name_properties_applied_by_user_principal_name: str - :ivar principal_id_properties_reviewed_by_principal_id: The identity id. - :vartype principal_id_properties_reviewed_by_principal_id: str - :ivar principal_type_properties_reviewed_by_principal_type: The identity type : - user/servicePrincipal. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. - :vartype principal_name_properties_reviewed_by_principal_name: str - :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal - name(if valid). - :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :param type_properties_target_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type type_properties_target_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'reviewed_date_time': {'readonly': True}, - 'apply_result': {'readonly': True}, - 'applied_date_time': {'readonly': True}, - 'principal_id_properties_applied_by_principal_id': {'readonly': True}, - 'principal_type_properties_applied_by_principal_type': {'readonly': True}, - 'principal_name_properties_applied_by_principal_name': {'readonly': True}, - 'user_principal_name_properties_applied_by_user_principal_name': {'readonly': True}, - 'principal_id_properties_reviewed_by_principal_id': {'readonly': True}, - 'principal_type_properties_reviewed_by_principal_type': {'readonly': True}, - 'principal_name_properties_reviewed_by_principal_name': {'readonly': True}, - 'user_principal_name_properties_reviewed_by_user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'decision': {'key': 'properties.decision', 'type': 'str'}, - 'justification': {'key': 'properties.justification', 'type': 'str'}, - 'reviewed_date_time': {'key': 'properties.reviewedDateTime', 'type': 'iso-8601'}, - 'apply_result': {'key': 'properties.applyResult', 'type': 'str'}, - 'applied_date_time': {'key': 'properties.appliedDateTime', 'type': 'iso-8601'}, - 'principal_id_properties_applied_by_principal_id': {'key': 'properties.appliedBy.principalId', 'type': 'str'}, - 'principal_type_properties_applied_by_principal_type': {'key': 'properties.appliedBy.principalType', 'type': 'str'}, - 'principal_name_properties_applied_by_principal_name': {'key': 'properties.appliedBy.principalName', 'type': 'str'}, - 'user_principal_name_properties_applied_by_user_principal_name': {'key': 'properties.appliedBy.userPrincipalName', 'type': 'str'}, - 'principal_id_properties_reviewed_by_principal_id': {'key': 'properties.reviewedBy.principalId', 'type': 'str'}, - 'principal_type_properties_reviewed_by_principal_type': {'key': 'properties.reviewedBy.principalType', 'type': 'str'}, - 'principal_name_properties_reviewed_by_principal_name': {'key': 'properties.reviewedBy.principalName', 'type': 'str'}, - 'user_principal_name_properties_reviewed_by_user_principal_name': {'key': 'properties.reviewedBy.userPrincipalName', 'type': 'str'}, - 'type_properties_target_type': {'key': 'properties.target.type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecision, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_properties_applied_by_principal_id = None - self.principal_type_properties_applied_by_principal_type = None - self.principal_name_properties_applied_by_principal_name = None - self.user_principal_name_properties_applied_by_user_principal_name = None - self.principal_id_properties_reviewed_by_principal_id = None - self.principal_type_properties_reviewed_by_principal_type = None - self.principal_name_properties_reviewed_by_principal_name = None - self.user_principal_name_properties_reviewed_by_user_principal_name = None - self.type_properties_target_type = None # type: Optional[str] - - -class AccessReviewDecisionListResult(msrest.serialization.Model): - """List of access review decisions. - - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewDecision]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewDecisionProperties(msrest.serialization.Model): - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_applied_by_principal_id: The identity id. - :vartype principal_id_applied_by_principal_id: str - :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_applied_by_principal_name: The identity display name. - :vartype principal_name_applied_by_principal_name: str - :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_applied_by_user_principal_name: str - :ivar principal_id_reviewed_by_principal_id: The identity id. - :vartype principal_id_reviewed_by_principal_id: str - :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_reviewed_by_principal_name: The identity display name. - :vartype principal_name_reviewed_by_principal_name: str - :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_reviewed_by_user_principal_name: str - :param type: The type of decision target : User/ServicePrincipal.Constant filled by server. - Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - """ - - _validation = { - 'recommendation': {'readonly': True}, - 'reviewed_date_time': {'readonly': True}, - 'apply_result': {'readonly': True}, - 'applied_date_time': {'readonly': True}, - 'principal_id_applied_by_principal_id': {'readonly': True}, - 'principal_type_applied_by_principal_type': {'readonly': True}, - 'principal_name_applied_by_principal_name': {'readonly': True}, - 'user_principal_name_applied_by_user_principal_name': {'readonly': True}, - 'principal_id_reviewed_by_principal_id': {'readonly': True}, - 'principal_type_reviewed_by_principal_type': {'readonly': True}, - 'principal_name_reviewed_by_principal_name': {'readonly': True}, - 'user_principal_name_reviewed_by_user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'recommendation': {'key': 'recommendation', 'type': 'str'}, - 'decision': {'key': 'decision', 'type': 'str'}, - 'justification': {'key': 'justification', 'type': 'str'}, - 'reviewed_date_time': {'key': 'reviewedDateTime', 'type': 'iso-8601'}, - 'apply_result': {'key': 'applyResult', 'type': 'str'}, - 'applied_date_time': {'key': 'appliedDateTime', 'type': 'iso-8601'}, - 'principal_id_applied_by_principal_id': {'key': 'appliedBy.principalId', 'type': 'str'}, - 'principal_type_applied_by_principal_type': {'key': 'appliedBy.principalType', 'type': 'str'}, - 'principal_name_applied_by_principal_name': {'key': 'appliedBy.principalName', 'type': 'str'}, - 'user_principal_name_applied_by_user_principal_name': {'key': 'appliedBy.userPrincipalName', 'type': 'str'}, - 'principal_id_reviewed_by_principal_id': {'key': 'reviewedBy.principalId', 'type': 'str'}, - 'principal_type_reviewed_by_principal_type': {'key': 'reviewedBy.principalType', 'type': 'str'}, - 'principal_name_reviewed_by_principal_name': {'key': 'reviewedBy.principalName', 'type': 'str'}, - 'user_principal_name_reviewed_by_user_principal_name': {'key': 'reviewedBy.userPrincipalName', 'type': 'str'}, - 'type': {'key': 'target.type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionProperties, self).__init__(**kwargs) - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_applied_by_principal_id = None - self.principal_type_applied_by_principal_type = None - self.principal_name_applied_by_principal_name = None - self.user_principal_name_applied_by_user_principal_name = None - self.principal_id_reviewed_by_principal_id = None - self.principal_type_reviewed_by_principal_type = None - self.principal_name_reviewed_by_principal_name = None - self.user_principal_name_reviewed_by_user_principal_name = None - self.type = None # type: Optional[str] - - -class AccessReviewDecisionTarget(msrest.serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ServicePrincipalDecisionTarget, UserDecisionTarget. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - """ - - _validation = { - 'type': {'required': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'servicePrincipal': 'ServicePrincipalDecisionTarget', 'user': 'UserDecisionTarget'} - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionTarget, self).__init__(**kwargs) - self.type = None # type: Optional[str] - - -class AccessReviewDefaultSettings(msrest.serialization.Model): - """Access Review Default Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review default settings id. This is only going to be default. - :vartype id: str - :ivar name: The access review default settings name. This is always going to be Access Review - Default Settings. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'mail_notifications_enabled': {'key': 'properties.mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'properties.reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'properties.defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'properties.justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'properties.defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'properties.autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'properties.recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'properties.instanceDurationInDays', 'type': 'int'}, - 'type_properties_recurrence_range_type': {'key': 'properties.recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'properties.recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'properties.recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'properties.recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_properties_recurrence_pattern_type': {'key': 'properties.recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'properties.recurrence.pattern.interval', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDefaultSettings, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_recurrence_range_type = kwargs.get('type_properties_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_recurrence_pattern_type = kwargs.get('type_properties_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class AccessReviewInstance(msrest.serialization.Model): - """Access Review Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review instance id. - :vartype id: str - :ivar name: The access review instance name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar status: This read-only field specifies the status of an access review instance. Possible - values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type end_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - - -class AccessReviewInstanceListResult(msrest.serialization.Model): - """List of Access Review Instances. - - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewReviewer(msrest.serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewerType - """ - - _validation = { - 'principal_type': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'principal_type': {'key': 'principalType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewReviewer, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - - -class AccessReviewScheduleDefinition(msrest.serialization.Model): - """Access Review Schedule Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review schedule definition id. - :vartype id: str - :ivar name: The access review schedule definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a - review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be - assigned and instead be chosen dynamically. For example managers review or self review. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal - to review. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_properties_created_by_principal_type: The identity type : - user/servicePrincipal. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_created_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'reviewers_type': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'role_definition_id': {'readonly': True}, - 'principal_type_properties_scope_principal_type': {'readonly': True}, - 'principal_id': {'readonly': True}, - 'principal_type_properties_created_by_principal_type': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'description_for_admins': {'key': 'properties.descriptionForAdmins', 'type': 'str'}, - 'description_for_reviewers': {'key': 'properties.descriptionForReviewers', 'type': 'str'}, - 'reviewers': {'key': 'properties.reviewers', 'type': '[AccessReviewReviewer]'}, - 'reviewers_type': {'key': 'properties.reviewersType', 'type': 'str'}, - 'instances': {'key': 'properties.instances', 'type': '[AccessReviewInstance]'}, - 'resource_id': {'key': 'properties.scope.resourceId', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.scope.roleDefinitionId', 'type': 'str'}, - 'principal_type_properties_scope_principal_type': {'key': 'properties.scope.principalType', 'type': 'str'}, - 'mail_notifications_enabled': {'key': 'properties.settings.mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'properties.settings.reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'properties.settings.defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'properties.settings.justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'properties.settings.defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'properties.settings.autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'properties.settings.recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'properties.settings.instanceDurationInDays', 'type': 'int'}, - 'type_properties_settings_recurrence_range_type': {'key': 'properties.settings.recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'properties.settings.recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'properties.settings.recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'properties.settings.recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_properties_settings_recurrence_pattern_type': {'key': 'properties.settings.recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'properties.settings.recurrence.pattern.interval', 'type': 'int'}, - 'principal_id': {'key': 'properties.createdBy.principalId', 'type': 'str'}, - 'principal_type_properties_created_by_principal_type': {'key': 'properties.createdBy.principalType', 'type': 'str'}, - 'principal_name': {'key': 'properties.createdBy.principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'properties.createdBy.userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_settings_recurrence_range_type = kwargs.get('type_properties_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_settings_recurrence_pattern_type = kwargs.get('type_properties_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): - """List of Access Review Schedule Definitions. - - :param value: Access Review Schedule Definition list. - :type value: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewScheduleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a - review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be - assigned and instead be chosen dynamically. For example managers review or self review. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: - list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_created_by_principal_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - 'status': {'readonly': True}, - 'reviewers_type': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'role_definition_id': {'readonly': True}, - 'principal_type_scope_principal_type': {'readonly': True}, - 'principal_id': {'readonly': True}, - 'principal_type_created_by_principal_type': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'description_for_admins': {'key': 'descriptionForAdmins', 'type': 'str'}, - 'description_for_reviewers': {'key': 'descriptionForReviewers', 'type': 'str'}, - 'reviewers': {'key': 'reviewers', 'type': '[AccessReviewReviewer]'}, - 'reviewers_type': {'key': 'reviewersType', 'type': 'str'}, - 'instances': {'key': 'instances', 'type': '[AccessReviewInstance]'}, - 'resource_id': {'key': 'scope.resourceId', 'type': 'str'}, - 'role_definition_id': {'key': 'scope.roleDefinitionId', 'type': 'str'}, - 'principal_type_scope_principal_type': {'key': 'scope.principalType', 'type': 'str'}, - 'mail_notifications_enabled': {'key': 'settings.mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'settings.reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'settings.defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'settings.justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'settings.defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'settings.autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'settings.recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'settings.instanceDurationInDays', 'type': 'int'}, - 'type_settings_recurrence_range_type': {'key': 'settings.recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'settings.recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'settings.recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'settings.recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_settings_recurrence_pattern_type': {'key': 'settings.recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'settings.recurrence.pattern.interval', 'type': 'int'}, - 'principal_id': {'key': 'createdBy.principalId', 'type': 'str'}, - 'principal_type_created_by_principal_type': {'key': 'createdBy.principalType', 'type': 'str'}, - 'principal_name': {'key': 'createdBy.principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'createdBy.userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_settings_recurrence_range_type = kwargs.get('type_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_settings_recurrence_pattern_type = kwargs.get('type_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(msrest.serialization.Model): - """Settings of an Access Review. - - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - """ - - _attribute_map = { - 'mail_notifications_enabled': {'key': 'mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'instanceDurationInDays', 'type': 'int'}, - 'type_recurrence_range_type': {'key': 'recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_recurrence_pattern_type': {'key': 'recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'recurrence.pattern.interval', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleSettings, self).__init__(**kwargs) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_recurrence_range_type = kwargs.get('type_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_recurrence_pattern_type = kwargs.get('type_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorDefinitionProperties(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :param code: Error code of list gateway. - :type code: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinitionProperties, self).__init__(**kwargs) - self.message = None - self.code = kwargs.get('code', None) - - -class Operation(msrest.serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :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 ServicePrincipalDecisionTarget(AccessReviewDecisionTarget): - """Service Principal Decision Target. - - 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - :ivar principal_id: The id of service principal whose access is reviewed. - :vartype principal_id: str - :ivar principal_name: The display name of the service principal whose access was reviewed. - :vartype principal_name: str - :ivar app_id: The appId for the service principal entity being reviewed. - :vartype app_id: str - """ - - _validation = { - 'type': {'required': True}, - 'principal_id': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'app_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'principal_name': {'key': 'principalName', 'type': 'str'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServicePrincipalDecisionTarget, self).__init__(**kwargs) - self.type = 'servicePrincipal' # type: str - self.principal_id = None - self.principal_name = None - self.app_id = None - - -class UserDecisionTarget(AccessReviewDecisionTarget): - """User Decision Target. - - 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType - :ivar principal_id: The id of user whose access was reviewed. - :vartype principal_id: str - :ivar principal_name: The display name of the user whose access was reviewed. - :vartype principal_name: str - :ivar user_principal_name: The user principal name of the user whose access was reviewed. - :vartype user_principal_name: str - """ - - _validation = { - 'type': {'required': True}, - 'principal_id': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'principal_name': {'key': 'principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserDecisionTarget, self).__init__(**kwargs) - self.type = 'user' # type: str - self.principal_id = None - self.principal_name = None - self.user_principal_name = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py index e833c4d6e9e0..b1d1b2062317 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/models/_models_py3.py @@ -30,12 +30,13 @@ class AccessReviewDecision(msrest.serialization.Model): values include: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :vartype decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Possible values include: "New", @@ -67,10 +68,9 @@ class AccessReviewDecision(msrest.serialization.Model): :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :param type_properties_target_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type type_properties_target_type: str or + :ivar type_properties_target_type: The type of decision target : User/ServicePrincipal.Constant + filled by server. Possible values include: "user", "servicePrincipal". + :vartype type_properties_target_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ @@ -120,6 +120,15 @@ def __init__( justification: Optional[str] = None, **kwargs ): + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed", "DontKnow", "NotNotified". + :paramtype decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ super(AccessReviewDecision, self).__init__(**kwargs) self.id = None self.name = None @@ -144,10 +153,10 @@ def __init__( class AccessReviewDecisionListResult(msrest.serialization.Model): """List of access review decisions. - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Access Review Decision list. + :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -162,6 +171,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Access Review Decision list. + :paramtype value: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AccessReviewDecisionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -176,12 +192,13 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): values include: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :vartype decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Possible values include: "New", @@ -211,9 +228,9 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :vartype principal_name_reviewed_by_principal_name: str :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_reviewed_by_user_principal_name: str - :param type: The type of decision target : User/ServicePrincipal.Constant filled by server. + :ivar type: The type of decision target : User/ServicePrincipal.Constant filled by server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ _validation = { @@ -256,6 +273,15 @@ def __init__( justification: Optional[str] = None, **kwargs ): + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed", "DontKnow", "NotNotified". + :paramtype decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ super(AccessReviewDecisionProperties, self).__init__(**kwargs) self.recommendation = None self.decision = decision @@ -282,9 +308,9 @@ class AccessReviewDecisionTarget(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType """ _validation = { @@ -303,6 +329,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionTarget, self).__init__(**kwargs) self.type = None # type: Optional[str] @@ -319,50 +347,50 @@ class AccessReviewDefaultSettings(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or + :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or + :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _validation = { @@ -410,6 +438,53 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_properties_recurrence_range_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :paramtype type_properties_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewDefaultSettings, self).__init__(**kwargs) self.id = None self.name = None @@ -446,10 +521,10 @@ class AccessReviewInstance(msrest.serialization.Model): "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type end_date_time: ~datetime.datetime + :ivar start_date_time: The DateTime when the review instance is scheduled to be start. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The DateTime when the review instance is scheduled to end. + :vartype end_date_time: ~datetime.datetime """ _validation = { @@ -475,6 +550,12 @@ def __init__( end_date_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword start_date_time: The DateTime when the review instance is scheduled to be start. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The DateTime when the review instance is scheduled to end. + :paramtype end_date_time: ~datetime.datetime + """ super(AccessReviewInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -487,10 +568,10 @@ def __init__( class AccessReviewInstanceListResult(msrest.serialization.Model): """List of Access Review Instances. - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Access Review Instance list. + :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -505,6 +586,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Access Review Instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AccessReviewInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -515,8 +603,8 @@ class AccessReviewReviewer(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str + :ivar principal_id: The id of the reviewer(user/servicePrincipal). + :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: "user", "servicePrincipal". :vartype principal_type: str or @@ -538,6 +626,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ super(AccessReviewReviewer, self).__init__(**kwargs) self.principal_id = principal_id self.principal_type = None @@ -554,21 +646,21 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param display_name: The display name for the schedule definition. - :type display_name: str + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Possible values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be @@ -576,8 +668,8 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): Possible values include: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str @@ -587,50 +679,50 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): to review. Possible values include: "user", "servicePrincipal". :vartype principal_type_properties_scope_principal_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or + :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or + :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_properties_created_by_principal_type: The identity type : @@ -716,6 +808,68 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The + possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", + "numbered". + :paramtype type_properties_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, + monthly, etc. Possible values include: "weekly", "absoluteMonthly". + :paramtype type_properties_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewScheduleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -753,11 +907,11 @@ def __init__( class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): """List of Access Review Schedule Definitions. - :param value: Access Review Schedule Definition list. - :type value: + :ivar value: Access Review Schedule Definition list. + :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -772,6 +926,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Access Review Schedule Definition list. + :paramtype value: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -782,21 +943,21 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The display name for the schedule definition. - :type display_name: str + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Possible values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be @@ -804,8 +965,8 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Possible values include: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str @@ -815,50 +976,50 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Possible values include: "user", "servicePrincipal". :vartype principal_type_scope_principal_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScopePrincipalType - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or + :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or + :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. @@ -938,6 +1099,67 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: + list[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstance] + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :paramtype type_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) self.display_name = display_name self.status = None @@ -972,50 +1194,50 @@ def __init__( class AccessReviewScheduleSettings(msrest.serialization.Model): """Settings of an Access Review. - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or + :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values + include: "weekly", "absoluteMonthly". + :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _attribute_map = { @@ -1054,6 +1276,53 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_recurrence_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_recurrence_range_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible + values include: "weekly", "absoluteMonthly". + :paramtype type_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewScheduleSettings, self).__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled @@ -1074,8 +1343,8 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why an operation failed. - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { @@ -1088,6 +1357,11 @@ def __init__( error: Optional["ErrorDefinitionProperties"] = None, **kwargs ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2018_05_01_preview.models.ErrorDefinitionProperties + """ super(ErrorDefinition, self).__init__(**kwargs) self.error = error @@ -1099,8 +1373,8 @@ class ErrorDefinitionProperties(msrest.serialization.Model): :ivar message: Description of the error. :vartype message: str - :param code: Error code of list gateway. - :type code: str + :ivar code: Error code of list gateway. + :vartype code: str """ _validation = { @@ -1118,6 +1392,10 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ super(ErrorDefinitionProperties, self).__init__(**kwargs) self.message = None self.code = code @@ -1126,14 +1404,14 @@ def __init__( class Operation(msrest.serialization.Model): """The definition of a Microsoft.Authorization operation. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str """ _attribute_map = { @@ -1152,6 +1430,16 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.authorization.v2018_05_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -1192,6 +1480,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1202,10 +1492,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The result of a request to list Microsoft.Authorization operations. - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str """ _attribute_map = { @@ -1220,6 +1510,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.authorization.v2018_05_01_preview.models.Operation] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1232,9 +1528,9 @@ class ServicePrincipalDecisionTarget(AccessReviewDecisionTarget): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType :ivar principal_id: The id of service principal whose access is reviewed. :vartype principal_id: str :ivar principal_name: The display name of the service principal whose access was reviewed. @@ -1261,6 +1557,8 @@ def __init__( self, **kwargs ): + """ + """ super(ServicePrincipalDecisionTarget, self).__init__(**kwargs) self.type = 'servicePrincipal' # type: str self.principal_id = None @@ -1275,9 +1573,9 @@ class UserDecisionTarget(AccessReviewDecisionTarget): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2018_05_01_preview.models.DecisionTargetType :ivar principal_id: The id of user whose access was reviewed. :vartype principal_id: str :ivar principal_name: The display name of the user whose access was reviewed. @@ -1304,6 +1602,8 @@ def __init__( self, **kwargs ): + """ + """ super(UserDecisionTarget, self).__init__(**kwargs) self.type = 'user' # type: str self.principal_id = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py index 3825a6e7381e..e92ff52bce62 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_default_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewDefaultSettingsOperations(object): """AccessReviewDefaultSettingsOperations operations. @@ -44,11 +119,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,31 +136,28 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -94,18 +166,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace def put( self, - properties, # type: "_models.AccessReviewScheduleSettings" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + properties: "_models.AccessReviewScheduleSettings", + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleSettings :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDefaultSettings @@ -116,36 +191,32 @@ def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -154,4 +225,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py index 554fcef70f11..26fe0938de3c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstanceDecisionsOperations(object): """AccessReviewInstanceDecisionsOperations operations. @@ -45,13 +83,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable["_models.AccessReviewDecisionListResult"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,45 +97,48 @@ def list( :param id: The id of the access review instance. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +147,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py index 9f7048249338..fb27cc0e57d2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,139 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "decisionId": _SERIALIZER.url("decision_id", decision_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_patch_request( + schedule_definition_id: str, + id: str, + decision_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "decisionId": _SERIALIZER.url("decision_id", decision_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewInstanceMyDecisionsOperations(object): """AccessReviewInstanceMyDecisionsOperations operations. @@ -45,13 +162,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable["_models.AccessReviewDecisionListResult"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,44 +176,46 @@ def list( :param id: The id of the access review instance. :type id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,29 +224,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any + ) -> "_models.AccessReviewDecision": """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -146,33 +270,30 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -181,17 +302,19 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace def patch( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - properties, # type: "_models.AccessReviewDecisionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + schedule_definition_id: str, + id: str, + decision_id: str, + properties: "_models.AccessReviewDecisionProperties", + **kwargs: Any + ) -> "_models.AccessReviewDecision": """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -201,7 +324,8 @@ def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecisionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewDecision @@ -212,38 +336,34 @@ def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -252,4 +372,6 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py index c9630800f4b7..cbdbe7b43c2f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instance_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_stop_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_reset_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_apply_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_send_reminders_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_accept_recommendations_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstanceOperations(object): """AccessReviewInstanceOperations operations. @@ -44,13 +224,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -67,47 +247,45 @@ def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore - def reset_decisions( + + @distributed_trace + def reset_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -124,47 +302,45 @@ def reset_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + - def apply_decisions( + @distributed_trace + def apply_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -181,47 +357,45 @@ def apply_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + - def send_reminders( + @distributed_trace + def send_reminders( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -238,47 +412,45 @@ def send_reminders( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore - def accept_recommendations( + + @distributed_trace + def accept_recommendations( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -295,35 +467,33 @@ def accept_recommendations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - accept_recommendations.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py index 84f0ecf936a4..89f77a919851 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,90 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstancesAssignedForMyApprovalOperations(object): """AccessReviewInstancesAssignedForMyApprovalOperations operations. @@ -45,54 +113,55 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + **kwargs: Any + ) -> Iterable["_models.AccessReviewInstanceListResult"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,28 +170,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -139,32 +213,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -173,4 +244,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py index d59e18077916..c4ccf3becc30 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstancesOperations(object): """AccessReviewInstancesOperations operations. @@ -45,55 +117,57 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + **kwargs: Any + ) -> Iterable["_models.AccessReviewInstanceListResult"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,28 +176,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -140,33 +219,30 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -175,4 +251,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index 9c137da7b56d..f48c4702e240 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations. @@ -45,47 +73,50 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + **kwargs: Any + ) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"]: """Get access review instances assigned for my approval. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +125,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py index c66ac2cf646b..e3b651da7818 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request( + schedule_definition_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsOperations(object): """AccessReviewScheduleDefinitionsOperations operations. @@ -45,51 +224,52 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + **kwargs: Any + ) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"]: """Get access review schedule definitions. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,27 +278,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + schedule_definition_id: str, + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -133,32 +318,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -167,14 +349,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -189,52 +373,51 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace def create_or_update_by_id( self, - schedule_definition_id, # type: str - properties, # type: "_models.AccessReviewScheduleDefinitionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + schedule_definition_id: str, + properties: "_models.AccessReviewScheduleDefinitionProperties", + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_05_01_preview.models.AccessReviewScheduleDefinition @@ -245,37 +428,33 @@ def create_or_update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -284,14 +463,16 @@ def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -306,35 +487,33 @@ def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py index 82a69202c8fc..87f51908a8b8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_05_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_05_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-05-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-05-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py index fe329ce394c1..308251cd9661 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_authorization_management_client.py @@ -6,73 +6,84 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to get deny + assignments. A deny assignment describes the set of actions on resources that are denied for + Azure Active Directory users. :ivar deny_assignments: DenyAssignmentsOperations operations - :vartype deny_assignments: azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations + :vartype deny_assignments: + azure.mgmt.authorization.v2018_07_01_preview.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deny_assignments = DenyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py index 12ef59d35da0..4de2cccb8d38 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-07-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json index 0666c785851c..39e7f82a0881 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "deny_assignments": "DenyAssignmentsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py index d2bb50dc9de8..089578963308 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_authorization_management_client.py @@ -6,69 +6,84 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import DenyAssignmentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to get deny assignments. A deny assignment describes the set of actions on resources that are denied for Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to get deny + assignments. A deny assignment describes the set of actions on resources that are denied for + Azure Active Directory users. :ivar deny_assignments: DenyAssignmentsOperations operations - :vartype deny_assignments: azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations + :vartype deny_assignments: + azure.mgmt.authorization.v2018_07_01_preview.aio.operations.DenyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.deny_assignments = DenyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.deny_assignments = DenyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py index f2b03196299e..137b8de4b16b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-07-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py index d18c4796ca47..9a76f2365d75 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/aio/operations/_deny_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._deny_assignments_operations import build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -72,53 +77,59 @@ def list_for_resource( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,21 +138,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -161,49 +178,51 @@ def list_for_resource_group( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -212,21 +231,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list( self, filter: Optional[str] = None, @@ -243,48 +268,49 @@ def list( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -293,21 +319,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace_async async def get( self, scope: str, @@ -330,32 +362,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_assignment_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + deny_assignment_id=deny_assignment_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -364,8 +393,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, deny_assignment_id: str, @@ -389,31 +421,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_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') + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + deny_assignment_id=deny_assignment_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -422,8 +451,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{denyAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{denyAssignmentId}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, @@ -443,48 +475,49 @@ def list_for_scope( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -493,17 +526,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py index 61272d33ee63..72781cfd661b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/__init__.py @@ -6,24 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import DenyAssignment - from ._models_py3 import DenyAssignmentFilter - from ._models_py3 import DenyAssignmentListResult - from ._models_py3 import DenyAssignmentPermission - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import Principal -except (SyntaxError, ImportError): - from ._models import DenyAssignment # type: ignore - from ._models import DenyAssignmentFilter # type: ignore - from ._models import DenyAssignmentListResult # type: ignore - from ._models import DenyAssignmentPermission # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Principal # type: ignore +from ._models_py3 import DenyAssignment +from ._models_py3 import DenyAssignmentFilter +from ._models_py3 import DenyAssignmentListResult +from ._models_py3 import DenyAssignmentPermission +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import Principal + __all__ = [ 'DenyAssignment', diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py deleted file mode 100644 index d3b3f6701114..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models.py +++ /dev/null @@ -1,290 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class DenyAssignment(msrest.serialization.Model): - """Deny Assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The deny assignment ID. - :vartype id: str - :ivar name: The deny assignment name. - :vartype name: str - :ivar type: The deny assignment type. - :vartype type: str - :param deny_assignment_name: The display name of the deny assignment. - :type deny_assignment_name: str - :param description: The description of the deny assignment. - :type description: str - :param permissions: An array of permissions that are denied by the deny assignment. - :type permissions: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] - :param scope: The deny assignment scope. - :type scope: str - :param do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. - Default value is false. - :type do_not_apply_to_child_scopes: bool - :param principals: Array of principals to which the deny assignment applies. - :type principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param exclude_principals: Array of principals to which the deny assignment does not apply. - :type exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param is_system_protected: Specifies whether this deny assignment was created by Azure and - cannot be edited or deleted. - :type is_system_protected: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'deny_assignment_name': {'key': 'properties.denyAssignmentName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'permissions': {'key': 'properties.permissions', 'type': '[DenyAssignmentPermission]'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'do_not_apply_to_child_scopes': {'key': 'properties.doNotApplyToChildScopes', 'type': 'bool'}, - 'principals': {'key': 'properties.principals', 'type': '[Principal]'}, - 'exclude_principals': {'key': 'properties.excludePrincipals', 'type': '[Principal]'}, - 'is_system_protected': {'key': 'properties.isSystemProtected', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DenyAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.deny_assignment_name = kwargs.get('deny_assignment_name', None) - self.description = kwargs.get('description', None) - self.permissions = kwargs.get('permissions', None) - self.scope = kwargs.get('scope', None) - self.do_not_apply_to_child_scopes = kwargs.get('do_not_apply_to_child_scopes', None) - self.principals = kwargs.get('principals', None) - self.exclude_principals = kwargs.get('exclude_principals', None) - self.is_system_protected = kwargs.get('is_system_protected', None) - - -class DenyAssignmentFilter(msrest.serialization.Model): - """Deny Assignments filter. - - :param deny_assignment_name: Return deny assignment with specified name. - :type deny_assignment_name: str - :param principal_id: Return all deny assignments where the specified principal is listed in the - principals list of deny assignments. - :type principal_id: str - :param gdpr_export_principal_id: Return all deny assignments where the specified principal is - listed either in the principals list or exclude principals list of deny assignments. - :type gdpr_export_principal_id: str - """ - - _attribute_map = { - 'deny_assignment_name': {'key': 'denyAssignmentName', 'type': 'str'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'gdpr_export_principal_id': {'key': 'gdprExportPrincipalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DenyAssignmentFilter, self).__init__(**kwargs) - self.deny_assignment_name = kwargs.get('deny_assignment_name', None) - self.principal_id = kwargs.get('principal_id', None) - self.gdpr_export_principal_id = kwargs.get('gdpr_export_principal_id', None) - - -class DenyAssignmentListResult(msrest.serialization.Model): - """Deny assignment list operation result. - - :param value: Deny assignment list. - :type value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[DenyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DenyAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class DenyAssignmentPermission(msrest.serialization.Model): - """Deny assignment permissions. - - :param actions: Actions to which the deny assignment does not grant access. - :type actions: list[str] - :param not_actions: Actions to exclude from that the deny assignment does not grant access. - :type not_actions: list[str] - :param data_actions: Data actions to which the deny assignment does not grant access. - :type data_actions: list[str] - :param not_data_actions: Data actions to exclude from that the deny assignment does not grant - access. - :type not_data_actions: list[str] - """ - - _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - 'data_actions': {'key': 'dataActions', 'type': '[str]'}, - 'not_data_actions': {'key': 'notDataActions', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(DenyAssignmentPermission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - self.data_actions = kwargs.get('data_actions', None) - self.not_data_actions = kwargs.get('not_data_actions', None) - - -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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Principal(msrest.serialization.Model): - """The name of the entity last modified it. - - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type email: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Principal, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - self.email = kwargs.get('email', None) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py index 50386332c7cd..4c940cb1e6ae 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/models/_models_py3.py @@ -23,25 +23,26 @@ class DenyAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The deny assignment type. :vartype type: str - :param deny_assignment_name: The display name of the deny assignment. - :type deny_assignment_name: str - :param description: The description of the deny assignment. - :type description: str - :param permissions: An array of permissions that are denied by the deny assignment. - :type permissions: + :ivar deny_assignment_name: The display name of the deny assignment. + :vartype deny_assignment_name: str + :ivar description: The description of the deny assignment. + :vartype description: str + :ivar permissions: An array of permissions that are denied by the deny assignment. + :vartype permissions: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] - :param scope: The deny assignment scope. - :type scope: str - :param do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. + :ivar scope: The deny assignment scope. + :vartype scope: str + :ivar do_not_apply_to_child_scopes: Determines if the deny assignment applies to child scopes. Default value is false. - :type do_not_apply_to_child_scopes: bool - :param principals: Array of principals to which the deny assignment applies. - :type principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param exclude_principals: Array of principals to which the deny assignment does not apply. - :type exclude_principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] - :param is_system_protected: Specifies whether this deny assignment was created by Azure and + :vartype do_not_apply_to_child_scopes: bool + :ivar principals: Array of principals to which the deny assignment applies. + :vartype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] + :ivar exclude_principals: Array of principals to which the deny assignment does not apply. + :vartype exclude_principals: + list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] + :ivar is_system_protected: Specifies whether this deny assignment was created by Azure and cannot be edited or deleted. - :type is_system_protected: bool + :vartype is_system_protected: bool """ _validation = { @@ -77,6 +78,28 @@ def __init__( is_system_protected: Optional[bool] = None, **kwargs ): + """ + :keyword deny_assignment_name: The display name of the deny assignment. + :paramtype deny_assignment_name: str + :keyword description: The description of the deny assignment. + :paramtype description: str + :keyword permissions: An array of permissions that are denied by the deny assignment. + :paramtype permissions: + list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentPermission] + :keyword scope: The deny assignment scope. + :paramtype scope: str + :keyword do_not_apply_to_child_scopes: Determines if the deny assignment applies to child + scopes. Default value is false. + :paramtype do_not_apply_to_child_scopes: bool + :keyword principals: Array of principals to which the deny assignment applies. + :paramtype principals: list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] + :keyword exclude_principals: Array of principals to which the deny assignment does not apply. + :paramtype exclude_principals: + list[~azure.mgmt.authorization.v2018_07_01_preview.models.Principal] + :keyword is_system_protected: Specifies whether this deny assignment was created by Azure and + cannot be edited or deleted. + :paramtype is_system_protected: bool + """ super(DenyAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -94,14 +117,14 @@ def __init__( class DenyAssignmentFilter(msrest.serialization.Model): """Deny Assignments filter. - :param deny_assignment_name: Return deny assignment with specified name. - :type deny_assignment_name: str - :param principal_id: Return all deny assignments where the specified principal is listed in the + :ivar deny_assignment_name: Return deny assignment with specified name. + :vartype deny_assignment_name: str + :ivar principal_id: Return all deny assignments where the specified principal is listed in the principals list of deny assignments. - :type principal_id: str - :param gdpr_export_principal_id: Return all deny assignments where the specified principal is + :vartype principal_id: str + :ivar gdpr_export_principal_id: Return all deny assignments where the specified principal is listed either in the principals list or exclude principals list of deny assignments. - :type gdpr_export_principal_id: str + :vartype gdpr_export_principal_id: str """ _attribute_map = { @@ -118,6 +141,16 @@ def __init__( gdpr_export_principal_id: Optional[str] = None, **kwargs ): + """ + :keyword deny_assignment_name: Return deny assignment with specified name. + :paramtype deny_assignment_name: str + :keyword principal_id: Return all deny assignments where the specified principal is listed in + the principals list of deny assignments. + :paramtype principal_id: str + :keyword gdpr_export_principal_id: Return all deny assignments where the specified principal is + listed either in the principals list or exclude principals list of deny assignments. + :paramtype gdpr_export_principal_id: str + """ super(DenyAssignmentFilter, self).__init__(**kwargs) self.deny_assignment_name = deny_assignment_name self.principal_id = principal_id @@ -127,10 +160,10 @@ def __init__( class DenyAssignmentListResult(msrest.serialization.Model): """Deny assignment list operation result. - :param value: Deny assignment list. - :type value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Deny assignment list. + :vartype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -145,6 +178,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Deny assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DenyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -153,15 +192,15 @@ def __init__( class DenyAssignmentPermission(msrest.serialization.Model): """Deny assignment permissions. - :param actions: Actions to which the deny assignment does not grant access. - :type actions: list[str] - :param not_actions: Actions to exclude from that the deny assignment does not grant access. - :type not_actions: list[str] - :param data_actions: Data actions to which the deny assignment does not grant access. - :type data_actions: list[str] - :param not_data_actions: Data actions to exclude from that the deny assignment does not grant + :ivar actions: Actions to which the deny assignment does not grant access. + :vartype actions: list[str] + :ivar not_actions: Actions to exclude from that the deny assignment does not grant access. + :vartype not_actions: list[str] + :ivar data_actions: Data actions to which the deny assignment does not grant access. + :vartype data_actions: list[str] + :ivar not_data_actions: Data actions to exclude from that the deny assignment does not grant access. - :type not_data_actions: list[str] + :vartype not_data_actions: list[str] """ _attribute_map = { @@ -180,6 +219,17 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :keyword actions: Actions to which the deny assignment does not grant access. + :paramtype actions: list[str] + :keyword not_actions: Actions to exclude from that the deny assignment does not grant access. + :paramtype not_actions: list[str] + :keyword data_actions: Data actions to which the deny assignment does not grant access. + :paramtype data_actions: list[str] + :keyword not_data_actions: Data actions to exclude from that the deny assignment does not grant + access. + :paramtype not_data_actions: list[str] + """ super(DenyAssignmentPermission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -212,6 +262,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -255,6 +307,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -266,8 +320,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail """ _attribute_map = { @@ -280,6 +334,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2018_07_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -287,14 +345,14 @@ def __init__( class Principal(msrest.serialization.Model): """The name of the entity last modified it. - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type email: str + :ivar id: The id of the principal made changes. + :vartype id: str + :ivar display_name: The name of the principal made changes. + :vartype display_name: str + :ivar type: Type of principal such as user , group etc. + :vartype type: str + :ivar email: Email of principal. + :vartype email: str """ _attribute_map = { @@ -313,6 +371,16 @@ def __init__( email: Optional[str] = None, **kwargs ): + """ + :keyword id: The id of the principal made changes. + :paramtype id: str + :keyword display_name: The name of the principal made changes. + :paramtype display_name: str + :keyword type: Type of principal such as user , group etc. + :paramtype type: str + :keyword email: Email of principal. + :paramtype email: str + """ super(Principal, self).__init__(**kwargs) self.id = id self.display_name = display_name diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py index 1c22aa2904b1..07c15f0d9baa 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_07_01_preview/operations/_deny_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,246 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_request( + subscription_id: str, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + deny_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + deny_assignment_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{denyAssignmentId}") + path_format_arguments = { + "denyAssignmentId": _SERIALIZER.url("deny_assignment_id", deny_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/denyAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class DenyAssignmentsOperations(object): """DenyAssignmentsOperations operations. @@ -45,17 +269,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_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.DenyAssignmentListResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DenyAssignmentListResult"]: """Gets deny assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -77,53 +301,59 @@ def list_for_resource( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,28 +362,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DenyAssignmentListResult"]: """Gets deny assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -167,49 +402,51 @@ def list_for_resource_group( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -218,27 +455,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DenyAssignmentListResult"]: """Gets all deny assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all deny @@ -250,48 +492,49 @@ def list( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -300,28 +543,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - deny_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DenyAssignment" + scope: str, + deny_assignment_id: str, + **kwargs: Any + ) -> "_models.DenyAssignment": """Get the specified deny assignment. :param scope: The scope of the deny assignment. @@ -338,32 +586,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_assignment_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + deny_assignment_id=deny_assignment_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -372,14 +617,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments/{denyAssignmentId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - deny_assignment_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.DenyAssignment" + deny_assignment_id: str, + **kwargs: Any + ) -> "_models.DenyAssignment": """Gets a deny assignment by ID. :param deny_assignment_id: The fully qualified deny assignment ID. For example, use the format, @@ -398,31 +645,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'denyAssignmentId': self._serialize.url("deny_assignment_id", deny_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') + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + deny_assignment_id=deny_assignment_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DenyAssignment', pipeline_response) @@ -431,15 +675,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{denyAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{denyAssignmentId}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.DenyAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.DenyAssignmentListResult"]: """Gets deny assignments for a scope. :param scope: The scope of the deny assignments. @@ -453,48 +699,49 @@ def list_for_scope( returns not only those deny assignments that contain the specified principal is the Principals list but also those deny assignments that contain the specified principal is the ExcludePrincipals list. Additionally, when gdprExportPrincipalId filter is used, only the deny - assignment name and description properties are returned. + assignment name and description properties are returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DenyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] + :return: An iterator like instance of either DenyAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_07_01_preview.models.DenyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-07-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.DenyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('DenyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("DenyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -503,17 +750,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/denyAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/denyAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py index 44241ef6b928..cd7ce3b867e2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_authorization_management_client.py @@ -6,73 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2018_09_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py index 4733e535b56d..48129d62ee8e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-09-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json index bdd80a44a1a9..8f666e6ab321 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignments": "RoleAssignmentsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py index 72b80ff6ea12..befc2ce841d0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_authorization_management_client.py @@ -6,69 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2018_09_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py index 73519a2fc10d..66cd0153d49a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2018-09-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2018-09-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py index 0d07516a09a1..423921d7ab6f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/aio/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -65,53 +70,59 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,21 +131,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -147,49 +164,51 @@ def list_for_resource_group( :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,21 +217,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, @@ -235,32 +260,29 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -271,8 +293,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, @@ -289,11 +314,12 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment @@ -304,37 +330,33 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -343,8 +365,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -367,32 +392,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -401,8 +423,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_id: str, @@ -422,31 +447,28 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -457,8 +479,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_id: str, @@ -470,7 +495,8 @@ async def create_by_id( :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment @@ -481,36 +507,32 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -519,8 +541,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -540,31 +565,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -573,8 +595,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -584,48 +609,49 @@ def list( :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -634,21 +660,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, @@ -661,48 +693,49 @@ def list_for_scope( :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -711,17 +744,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py index 83bed7401315..870dec87abfb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/__init__.py @@ -6,22 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import RoleAssignment - from ._models_py3 import RoleAssignmentCreateParameters - from ._models_py3 import RoleAssignmentFilter - from ._models_py3 import RoleAssignmentListResult -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import RoleAssignment +from ._models_py3 import RoleAssignmentCreateParameters +from ._models_py3 import RoleAssignmentFilter +from ._models_py3 import RoleAssignmentListResult + from ._authorization_management_client_enums import ( PrincipalType, diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py index c60129f05bca..12cdb7b790d1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_authorization_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The principal type of the assigned principal ID. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py deleted file mode 100644 index e7eec8469933..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models.py +++ /dev/null @@ -1,247 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class RoleAssignment(msrest.serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'can_delegate': {'key': 'properties.canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool - """ - - _validation = { - 'role_definition_id': {'required': True}, - 'principal_id': {'required': True}, - } - - _attribute_map = { - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'can_delegate': {'key': 'properties.canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'can_delegate': {'key': 'canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py index a6dbf45a8abe..5c8244ca163c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/models/_models_py3.py @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -82,6 +84,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -93,8 +97,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail """ _attribute_map = { @@ -107,6 +111,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2018_09_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -122,17 +130,18 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :ivar scope: The role assignment scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType + :ivar can_delegate: The Delegation flag for the role assignment. + :vartype can_delegate: bool """ _validation = { @@ -162,6 +171,20 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword scope: The role assignment scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType + :keyword can_delegate: The Delegation flag for the role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -178,16 +201,17 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. The principal ID assigned to the role. This maps to the ID inside + the Active Directory. It can point to a user, service principal, or security group. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType + :ivar can_delegate: The delegation flag used for creating a role assignment. + :vartype can_delegate: bool """ _validation = { @@ -211,6 +235,19 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. The principal ID assigned to the role. This maps to the ID + inside the Active Directory. It can point to a user, service principal, or security group. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2018_09_01_preview.models.PrincipalType + :keyword can_delegate: The delegation flag used for creating a role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -221,10 +258,10 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str + :ivar can_delegate: The Delegation flag for the role assignment. + :vartype can_delegate: bool """ _attribute_map = { @@ -239,6 +276,12 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + :keyword can_delegate: The Delegation flag for the role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate @@ -247,10 +290,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role assignment list. + :vartype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -265,6 +308,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py index 5c0f8f71739b..6f114d3cb9c7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2018_09_01_preview/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,395 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,17 +418,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_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.RoleAssignmentListResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -70,53 +443,59 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,77 +504,84 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,28 +590,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Deletes a role assignment. :param scope: The scope of the role assignment to delete. @@ -242,32 +633,29 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -278,16 +666,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -297,11 +687,12 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment @@ -312,37 +703,33 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -351,15 +738,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + **kwargs: Any + ) -> "_models.RoleAssignment": """Get the specified role assignment. :param scope: The scope of the role assignment. @@ -376,32 +765,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -410,14 +796,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_id: str, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Deletes a role assignment. :param role_id: The ID of the role assignment to delete. @@ -432,31 +820,28 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -467,21 +852,24 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignment @@ -492,36 +880,32 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -530,14 +914,16 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + **kwargs: Any + ) -> "_models.RoleAssignment": """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. @@ -552,31 +938,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -585,60 +968,63 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -647,76 +1033,82 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2018_09_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2018-09-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -725,17 +1117,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py index 7f4540945cef..0afce02c01fb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_authorization_management_client.py @@ -6,73 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations - :vartype role_assignment_metrics: azure.mgmt.authorization.v2019_08_01_preview.operations.RoleAssignmentMetricsOperations + :vartype role_assignment_metrics: + azure.mgmt.authorization.v2019_08_01_preview.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignment_metrics = RoleAssignmentMetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py index b98b95f68dae..2bddcf93739f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-08-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json index 9fc9a49ce493..1a0942f5657c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignment_metrics": "RoleAssignmentMetricsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py index c8cbf3acbd4e..f4b493b216fb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_authorization_management_client.py @@ -6,69 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentMetricsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignment_metrics: RoleAssignmentMetricsOperations operations - :vartype role_assignment_metrics: azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations + :vartype role_assignment_metrics: + azure.mgmt.authorization.v2019_08_01_preview.aio.operations.RoleAssignmentMetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignment_metrics = RoleAssignmentMetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_metrics = RoleAssignmentMetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py index c57152d3d991..34fbbbf7e817 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2019-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-08-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py index 62dd285c0dbf..2062a191c6c8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/aio/operations/_role_assignment_metrics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_metrics_operations import build_get_metrics_for_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_metrics_for_subscription( self, **kwargs: Any @@ -56,31 +60,28 @@ async def get_metrics_for_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_metrics_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + + + request = build_get_metrics_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_metrics_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentMetricsResult', pipeline_response) @@ -89,4 +90,6 @@ async def get_metrics_for_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - get_metrics_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics'} # type: ignore + + get_metrics_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py index 300a963b2dfb..561f2e98a4c5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/__init__.py @@ -6,16 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import RoleAssignmentMetricsResult -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import RoleAssignmentMetricsResult # type: ignore +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import RoleAssignmentMetricsResult + __all__ = [ 'ErrorAdditionalInfo', diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.py deleted file mode 100644 index 90b847f06ec7..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class RoleAssignmentMetricsResult(msrest.serialization.Model): - """Role Assignment Metrics. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar subscription_id: The subscription ID. - :vartype subscription_id: str - :ivar role_assignments_limit: The role assignment limit. - :vartype role_assignments_limit: long - :ivar role_assignments_current_count: The number of current role assignments. - :vartype role_assignments_current_count: long - :ivar role_assignments_remaining_count: The number of remaining role assignments available. - :vartype role_assignments_remaining_count: long - """ - - _validation = { - 'subscription_id': {'readonly': True}, - 'role_assignments_limit': {'readonly': True}, - 'role_assignments_current_count': {'readonly': True}, - 'role_assignments_remaining_count': {'readonly': True}, - } - - _attribute_map = { - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'role_assignments_limit': {'key': 'roleAssignmentsLimit', 'type': 'long'}, - 'role_assignments_current_count': {'key': 'roleAssignmentsCurrentCount', 'type': 'long'}, - 'role_assignments_remaining_count': {'key': 'roleAssignmentsRemainingCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentMetricsResult, self).__init__(**kwargs) - self.subscription_id = None - self.role_assignments_limit = None - self.role_assignments_current_count = None - self.role_assignments_remaining_count = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py index 286bd07d2b43..ccc19aa4c8a4 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/models/_models_py3.py @@ -37,6 +37,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -80,6 +82,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -91,8 +95,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail """ _attribute_map = { @@ -105,6 +109,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2019_08_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -142,6 +150,8 @@ def __init__( self, **kwargs ): + """ + """ super(RoleAssignmentMetricsResult, self).__init__(**kwargs) self.subscription_id = None self.role_assignments_limit = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py index 454ef3be9b16..646ad53fa4a7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2019_08_01_preview/operations/_role_assignment_metrics_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_metrics_for_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentMetricsOperations(object): """RoleAssignmentMetricsOperations operations. @@ -44,11 +78,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_metrics_for_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentMetricsResult" + **kwargs: Any + ) -> "_models.RoleAssignmentMetricsResult": """Get role assignment usage metrics for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,31 +95,28 @@ def get_metrics_for_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-08-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_metrics_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2019-08-01-preview") # type: str + + + request = build_get_metrics_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_metrics_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentMetricsResult', pipeline_response) @@ -94,4 +125,6 @@ def get_metrics_for_subscription( return cls(pipeline_response, deserialized, {}) return deserialized - get_metrics_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics'} # type: ignore + + get_metrics_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignmentsUsageMetrics"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py index 33609c807ffa..754406fc107d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_authorization_management_client.py @@ -6,73 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from . import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2020_04_01_preview.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2020_04_01_preview.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py index 68f02c44c0d2..50f7048797d0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-04-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json index 2343e9faff44..fa7c085931f6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignments": "RoleAssignmentsOperations" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py index e4d7629bf932..dfea394cc781 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_authorization_management_client.py @@ -6,69 +6,83 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from .. import models from ._configuration import AuthorizationManagementClientConfiguration from .operations import RoleAssignmentsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2020_04_01_preview.aio.operations.RoleAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py index 7ded355a0326..ab60c7ee2e73 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-04-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-04-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py index 1dcb19f36287..27c8e7141095 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/aio/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -66,57 +71,63 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,21 +136,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -153,53 +170,55 @@ def list_for_resource_group( :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -208,21 +227,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def delete( self, scope: str, @@ -236,7 +261,7 @@ async def delete( :type scope: str :param role_assignment_name: The name of the role assignment to delete. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -248,34 +273,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -286,8 +307,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, @@ -304,11 +328,12 @@ async def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment @@ -319,37 +344,33 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -358,8 +379,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -373,7 +397,7 @@ async def get( :type scope: str :param role_assignment_name: The name of the role assignment to get. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -385,34 +409,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -421,8 +441,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_id: str, @@ -433,7 +456,7 @@ async def delete_by_id( :param role_id: The ID of the role assignment to delete. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -445,33 +468,29 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -482,8 +501,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_id: str, @@ -495,7 +517,8 @@ async def create_by_id( :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment @@ -506,36 +529,32 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -544,8 +563,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace_async async def get_by_id( self, role_id: str, @@ -556,7 +578,7 @@ async def get_by_id( :param role_id: The ID of the role assignment to get. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -568,33 +590,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -603,8 +621,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, filter: Optional[str] = None, @@ -615,52 +636,53 @@ def list( :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -669,21 +691,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, scope: str, @@ -697,52 +725,53 @@ def list_for_scope( :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -751,17 +780,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py index 83bed7401315..870dec87abfb 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/__init__.py @@ -6,22 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import RoleAssignment - from ._models_py3 import RoleAssignmentCreateParameters - from ._models_py3 import RoleAssignmentFilter - from ._models_py3 import RoleAssignmentListResult -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import RoleAssignment +from ._models_py3 import RoleAssignmentCreateParameters +from ._models_py3 import RoleAssignmentFilter +from ._models_py3 import RoleAssignmentListResult + from ._authorization_management_client_enums import ( PrincipalType, diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py index c60129f05bca..12cdb7b790d1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_authorization_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The principal type of the assigned principal ID. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py deleted file mode 100644 index 538c4b092fee..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models.py +++ /dev/null @@ -1,301 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class 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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class RoleAssignment(msrest.serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: Time it was created. - :type created_on: ~datetime.datetime - :param updated_on: Time it was updated. - :type updated_on: ~datetime.datetime - :param created_by: Id of the user who created the assignment. - :type created_by: str - :param updated_by: Id of the user who updated the assignment. - :type updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'can_delegate': {'key': 'properties.canDelegate', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'updated_by': {'key': 'properties.updatedBy', 'type': 'str'}, - 'delegated_managed_identity_resource_id': {'key': 'properties.delegatedManagedIdentityResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.updated_on = kwargs.get('updated_on', None) - self.created_by = kwargs.get('created_by', None) - self.updated_by = kwargs.get('updated_by', None) - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - All required parameters must be populated in order to send to Azure. - - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str - """ - - _validation = { - 'role_definition_id': {'required': True}, - 'principal_id': {'required': True}, - } - - _attribute_map = { - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'can_delegate': {'key': 'properties.canDelegate', 'type': 'bool'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'delegated_managed_identity_resource_id': {'key': 'properties.delegatedManagedIdentityResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.principal_type = kwargs.get('principal_type', None) - self.can_delegate = kwargs.get('can_delegate', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'can_delegate': {'key': 'canDelegate', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.can_delegate = kwargs.get('can_delegate', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py index e16a85d38810..484303c996e8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/models/_models_py3.py @@ -40,6 +40,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -83,6 +85,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -94,8 +98,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail """ _attribute_map = { @@ -108,6 +112,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2020_04_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -123,36 +131,37 @@ class RoleAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment type. :vartype type: str - :param scope: The role assignment scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar scope: The role assignment scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType + :ivar can_delegate: The Delegation flag for the role assignment. + :vartype can_delegate: bool + :ivar description: Description of role assignment. + :vartype description: str + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: Time it was created. - :type created_on: ~datetime.datetime - :param updated_on: Time it was updated. - :type updated_on: ~datetime.datetime - :param created_by: Id of the user who created the assignment. - :type created_by: str - :param updated_by: Id of the user who updated the assignment. - :type updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: Time it was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: Time it was updated. + :vartype updated_on: ~datetime.datetime + :ivar created_by: Id of the user who created the assignment. + :vartype created_by: str + :ivar updated_by: Id of the user who updated the assignment. + :vartype updated_by: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str """ _validation = { @@ -198,6 +207,39 @@ def __init__( delegated_managed_identity_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword scope: The role assignment scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType + :keyword can_delegate: The Delegation flag for the role assignment. + :paramtype can_delegate: bool + :keyword description: Description of role assignment. + :paramtype description: str + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: Time it was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: Time it was updated. + :paramtype updated_on: ~datetime.datetime + :keyword created_by: Id of the user who created the assignment. + :paramtype created_by: str + :keyword updated_by: Id of the user who updated the assignment. + :paramtype updated_by: str + :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :paramtype delegated_managed_identity_resource_id: str + """ super(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -222,27 +264,28 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param role_definition_id: Required. The role definition ID used in the role assignment. - :type role_definition_id: str - :param principal_id: Required. The principal ID assigned to the role. This maps to the ID - inside the Active Directory. It can point to a user, service principal, or security group. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup". - :type principal_type: str or ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType - :param can_delegate: The delegation flag used for creating a role assignment. - :type can_delegate: bool - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar role_definition_id: Required. The role definition ID used in the role assignment. + :vartype role_definition_id: str + :ivar principal_id: Required. The principal ID assigned to the role. This maps to the ID inside + the Active Directory. It can point to a user, service principal, or security group. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType + :ivar can_delegate: The delegation flag used for creating a role assignment. + :vartype can_delegate: bool + :ivar description: Description of role assignment. + :vartype description: str + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str """ _validation = { @@ -274,6 +317,30 @@ def __init__( delegated_managed_identity_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID used in the role assignment. + :paramtype role_definition_id: str + :keyword principal_id: Required. The principal ID assigned to the role. This maps to the ID + inside the Active Directory. It can point to a user, service principal, or security group. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_04_01_preview.models.PrincipalType + :keyword can_delegate: The delegation flag used for creating a role assignment. + :paramtype can_delegate: bool + :keyword description: Description of role assignment. + :paramtype description: str + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :paramtype delegated_managed_identity_resource_id: str + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.role_definition_id = role_definition_id self.principal_id = principal_id @@ -288,10 +355,10 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - :param can_delegate: The Delegation flag for the role assignment. - :type can_delegate: bool + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str + :ivar can_delegate: The Delegation flag for the role assignment. + :vartype can_delegate: bool """ _attribute_map = { @@ -306,6 +373,12 @@ def __init__( can_delegate: Optional[bool] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + :keyword can_delegate: The Delegation flag for the role assignment. + :paramtype can_delegate: bool + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id self.can_delegate = can_delegate @@ -314,10 +387,10 @@ def __init__( class RoleAssignmentListResult(msrest.serialization.Model): """Role assignment list operation result. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role assignment list. + :vartype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -332,6 +405,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py index b6b21369439f..b395fcc5f512 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_04_01_preview/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,423 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_resource_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + "parentResourcePath": _SERIALIZER.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + resource_group_name: str, + subscription_id: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + role_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_id_request( + role_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleId}") + path_format_arguments = { + "roleId": _SERIALIZER.url("role_id", role_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,18 +446,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_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] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_path: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """List role assignments for a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -71,57 +472,63 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'parentResourcePath': self._serialize.url("parent_resource_path", parent_resource_path, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_path=parent_resource_path, + resource_type=resource_type, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,82 +537,89 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """List role assignments for a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -214,36 +628,41 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + scope: str, + role_assignment_name: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Delete a role assignment. :param scope: The scope of the role assignment to delete. :type scope: str :param role_assignment_name: The name of the role assignment to delete. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -255,34 +674,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -293,16 +708,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Create a role assignment. :param scope: The scope of the role assignment to create. The scope can be any REST resource @@ -312,11 +729,12 @@ def create( '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_name: The name of the role assignment to create. It can be any valid - GUID. + :param role_assignment_name: A GUID for the role assignment to create. The name must be unique + and different for each role assignment. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment @@ -327,37 +745,33 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -366,23 +780,25 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.RoleAssignment": """Get the specified role assignment. :param scope: The scope of the role assignment. :type scope: str :param role_assignment_name: The name of the role assignment to get. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -394,34 +810,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -430,20 +842,22 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_id: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Delete a role assignment. :param role_id: The ID of the role assignment to delete. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -455,33 +869,29 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -492,21 +902,24 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Creates a role assignment by ID. :param role_id: The ID of the role assignment to create. :type role_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignment @@ -517,36 +930,32 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_id=role_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -555,20 +964,22 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def get_by_id( self, - role_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_id: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.RoleAssignment": """Gets a role assignment by ID. :param role_id: The ID of the role assignment to get. :type role_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -580,33 +991,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleId': self._serialize.url("role_id", role_id, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_id=role_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -615,65 +1022,68 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleId}"} # type: ignore + + + @distributed_trace def list( self, - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets all role assignments for the subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -682,81 +1092,87 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """Gets role assignments for a scope. :param scope: The scope of the role assignments. :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_04_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-04-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-04-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -765,17 +1181,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py new file mode 100644 index 000000000000..6bee2d262ef1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._authorization_management_client import AuthorizationManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py new file mode 100644 index 000000000000..5aaad20943ce --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_authorization_management_client.py @@ -0,0 +1,128 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. + + :ivar eligible_child_resources: EligibleChildResourcesOperations operations + :vartype eligible_child_resources: + azure.mgmt.authorization.v2020_10_01.operations.EligibleChildResourcesOperations + :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations + :vartype role_assignment_schedules: + azure.mgmt.authorization.v2020_10_01.operations.RoleAssignmentSchedulesOperations + :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations + :vartype role_assignment_schedule_instances: + azure.mgmt.authorization.v2020_10_01.operations.RoleAssignmentScheduleInstancesOperations + :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations + :vartype role_assignment_schedule_requests: + azure.mgmt.authorization.v2020_10_01.operations.RoleAssignmentScheduleRequestsOperations + :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations + :vartype role_eligibility_schedules: + azure.mgmt.authorization.v2020_10_01.operations.RoleEligibilitySchedulesOperations + :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations + operations + :vartype role_eligibility_schedule_instances: + azure.mgmt.authorization.v2020_10_01.operations.RoleEligibilityScheduleInstancesOperations + :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations + :vartype role_eligibility_schedule_requests: + azure.mgmt.authorization.v2020_10_01.operations.RoleEligibilityScheduleRequestsOperations + :ivar role_management_policies: RoleManagementPoliciesOperations operations + :vartype role_management_policies: + azure.mgmt.authorization.v2020_10_01.operations.RoleManagementPoliciesOperations + :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations + :vartype role_management_policy_assignments: + azure.mgmt.authorization.v2020_10_01.operations.RoleManagementPolicyAssignmentsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.eligible_child_resources = EligibleChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policies = RoleManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AuthorizationManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py new file mode 100644 index 000000000000..c953ef181762 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_configuration.py @@ -0,0 +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. +# Code generated 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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AuthorizationManagementClient. + + 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.TokenCredential + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json new file mode 100644 index 000000000000..0b794e4af545 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_metadata.json @@ -0,0 +1,98 @@ +{ + "chosen_version": "2020-10-01", + "total_api_version_list": ["2020-10-01"], + "client": { + "name": "AuthorizationManagementClient", + "filename": "_authorization_management_client", + "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + } + }, + "constant": { + }, + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "eligible_child_resources": "EligibleChildResourcesOperations", + "role_assignment_schedules": "RoleAssignmentSchedulesOperations", + "role_assignment_schedule_instances": "RoleAssignmentScheduleInstancesOperations", + "role_assignment_schedule_requests": "RoleAssignmentScheduleRequestsOperations", + "role_eligibility_schedules": "RoleEligibilitySchedulesOperations", + "role_eligibility_schedule_instances": "RoleEligibilityScheduleInstancesOperations", + "role_eligibility_schedule_requests": "RoleEligibilityScheduleRequestsOperations", + "role_management_policies": "RoleManagementPoliciesOperations", + "role_management_policy_assignments": "RoleManagementPolicyAssignmentsOperations" + } +} \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/_version.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__init__.py new file mode 100644 index 000000000000..e2872ec3f27d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/__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_management_client import AuthorizationManagementClient +__all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py new file mode 100644 index 000000000000..192d877e668f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_authorization_management_client.py @@ -0,0 +1,125 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. + + :ivar eligible_child_resources: EligibleChildResourcesOperations operations + :vartype eligible_child_resources: + azure.mgmt.authorization.v2020_10_01.aio.operations.EligibleChildResourcesOperations + :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations + :vartype role_assignment_schedules: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentSchedulesOperations + :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations + :vartype role_assignment_schedule_instances: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleInstancesOperations + :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations + :vartype role_assignment_schedule_requests: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleAssignmentScheduleRequestsOperations + :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations + :vartype role_eligibility_schedules: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilitySchedulesOperations + :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations + operations + :vartype role_eligibility_schedule_instances: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleInstancesOperations + :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations + :vartype role_eligibility_schedule_requests: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleEligibilityScheduleRequestsOperations + :ivar role_management_policies: RoleManagementPoliciesOperations operations + :vartype role_management_policies: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPoliciesOperations + :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations + :vartype role_management_policy_assignments: + azure.mgmt.authorization.v2020_10_01.aio.operations.RoleManagementPolicyAssignmentsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.eligible_child_resources = EligibleChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policies = RoleManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AuthorizationManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.py new file mode 100644 index 000000000000..cc2e871193fb --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_configuration.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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AuthorizationManagementClient. + + 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 + :keyword api_version: Api Version. Default value is "2020-10-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + + self.credential = credential + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py new file mode 100644 index 000000000000..2c6abd246591 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._eligible_child_resources_operations import EligibleChildResourcesOperations +from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations +from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations +from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations +from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations +from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations +from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations +from ._role_management_policies_operations import RoleManagementPoliciesOperations +from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations + +__all__ = [ + 'EligibleChildResourcesOperations', + 'RoleAssignmentSchedulesOperations', + 'RoleAssignmentScheduleInstancesOperations', + 'RoleAssignmentScheduleRequestsOperations', + 'RoleEligibilitySchedulesOperations', + 'RoleEligibilityScheduleInstancesOperations', + 'RoleEligibilityScheduleRequestsOperations', + 'RoleManagementPoliciesOperations', + 'RoleManagementPolicyAssignmentsOperations', +] diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py new file mode 100644 index 000000000000..25dab8a847bd --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_eligible_child_resources_operations.py @@ -0,0 +1,129 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._eligible_child_resources_operations import build_get_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class EligibleChildResourcesOperations: + """EligibleChildResourcesOperations 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.authorization.v2020_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 + + @distributed_trace + def get( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.EligibleChildResourcesListResult"]: + """Get the child resources of a resource on which user has eligible access. + + :param scope: The scope of the role management policy. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' + to filter on only resource of type = 'Subscription'. Use + $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource + of type = 'Subscription' or 'ResourceGroup'. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.EligibleChildResourcesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py new file mode 100644 index 000000000000..db475d6b37e0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_instances_operations.py @@ -0,0 +1,190 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleAssignmentScheduleInstancesOperations: + """RoleAssignmentScheduleInstancesOperations 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.authorization.v2020_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 + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RoleAssignmentScheduleInstanceListResult"]: + """Gets role assignment schedule instances of a role assignment schedule. + + :param scope: The scope of the role assignment schedule. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role + assignment schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. + Use $filter=asTarget() to return all role assignment schedule instances created for the current + user. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} # type: ignore + + @distributed_trace_async + async def get( + self, + scope: str, + role_assignment_schedule_instance_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleInstance": + """Gets the specified role assignment schedule instance. + + :param scope: The scope of the role assignments schedules. + :type scope: str + :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the + role assignment schedule to get. + :type role_assignment_schedule_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py new file mode 100644 index 000000000000..bbcb30904f60 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedule_requests_operations.py @@ -0,0 +1,380 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_assignment_schedule_requests_operations import build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request, build_validate_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleAssignmentScheduleRequestsOperations: + """RoleAssignmentScheduleRequestsOperations 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.authorization.v2020_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 + + @distributed_trace_async + async def create( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: "_models.RoleAssignmentScheduleRequest", + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": + """Creates a role assignment schedule request. + + :param scope: The scope of the role assignment schedule request to create. The scope can be any + REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a + subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a + resource group, and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' + for a resource. + :type scope: str + :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The + name must be unique and different for each role assignment. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_create_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": + """Get the specified role assignment schedule request. + + :param scope: The scope of the role assignment schedule request. + :type scope: str + :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule + request to get. + :type role_assignment_schedule_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RoleAssignmentScheduleRequestListResult"]: + """Gets role assignment schedule requests for a scope. + + :param scope: The scope of the role assignments schedule requests. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return + all role assignment schedule requests at, above or below the scope for the specified principal. + Use $filter=asRequestor() to return all role assignment schedule requests requested by the + current user. Use $filter=asTarget() to return all role assignment schedule requests created + for the current user. Use $filter=asApprover() to return all role assignment schedule requests + where the current user is an approver. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequestListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} # type: ignore + + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any + ) -> None: + """Cancels a pending role assignment schedule request. + + :param scope: The scope of the role assignment request to cancel. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + cancel. + :type role_assignment_schedule_request_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_cancel_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel"} # type: ignore + + + @distributed_trace_async + async def validate( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: "_models.RoleAssignmentScheduleRequest", + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": + """Validates a new role assignment schedule request. + + :param scope: The scope of the role assignment request to validate. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + validate. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_validate_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py new file mode 100644 index 000000000000..78a5a52a87fe --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_assignment_schedules_operations.py @@ -0,0 +1,189 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleAssignmentSchedulesOperations: + """RoleAssignmentSchedulesOperations 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.authorization.v2020_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 + + @distributed_trace_async + async def get( + self, + scope: str, + role_assignment_schedule_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentSchedule": + """Get the specified role assignment schedule for a resource scope. + + :param scope: The scope of the role assignment schedule. + :type scope: str + :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. + :type role_assignment_schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentSchedule, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentSchedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_assignment_schedule_name=role_assignment_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentSchedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RoleAssignmentScheduleListResult"]: + """Gets role assignment schedules for a resource scope. + + :param scope: The scope of the role assignments schedules. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role + assignment schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. + Use $filter=asTarget() to return all role assignment schedules created for the current user. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py new file mode 100644 index 000000000000..63e45bc58417 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_instances_operations.py @@ -0,0 +1,190 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_eligibility_schedule_instances_operations import build_get_request, build_list_for_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleEligibilityScheduleInstancesOperations: + """RoleEligibilityScheduleInstancesOperations 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.authorization.v2020_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 + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RoleEligibilityScheduleInstanceListResult"]: + """Gets role eligibility schedule instances of a role eligibility schedule. + + :param scope: The scope of the role eligibility schedule. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role + assignment schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use + $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} # type: ignore + + @distributed_trace_async + async def get( + self, + scope: str, + role_eligibility_schedule_instance_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleInstance": + """Gets the specified role eligibility schedule instance. + + :param scope: The scope of the role eligibility schedules. + :type scope: str + :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the + role eligibility schedule to get. + :type role_eligibility_schedule_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py new file mode 100644 index 000000000000..0ba3761929b2 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -0,0 +1,380 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_eligibility_schedule_requests_operations import build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request, build_validate_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleEligibilityScheduleRequestsOperations: + """RoleEligibilityScheduleRequestsOperations 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.authorization.v2020_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 + + @distributed_trace_async + async def create( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: "_models.RoleEligibilityScheduleRequest", + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": + """Creates a role eligibility schedule request. + + :param scope: The scope of the role eligibility schedule request to create. The scope can be + any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a + subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a + resource group, and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' + for a resource. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It + can be any valid GUID. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_create_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": + """Get the specified role eligibility schedule request. + + :param scope: The scope of the role eligibility schedule request. + :type scope: str + :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule + request to get. + :type role_eligibility_schedule_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RoleEligibilityScheduleRequestListResult"]: + """Gets role eligibility schedule requests for a scope. + + :param scope: The scope of the role eligibility schedule requests. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return + all role eligibility schedule requests at, above or below the scope for the specified + principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested + by the current user. Use $filter=asTarget() to return all role eligibility schedule requests + created for the current user. Use $filter=asApprover() to return all role eligibility schedule + requests where the current user is an approver. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequestListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} # type: ignore + + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any + ) -> None: + """Cancels a pending role eligibility schedule request. + + :param scope: The scope of the role eligibility request to cancel. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + cancel. + :type role_eligibility_schedule_request_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_cancel_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel"} # type: ignore + + + @distributed_trace_async + async def validate( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: "_models.RoleEligibilityScheduleRequest", + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": + """Validates a new role eligibility schedule request. + + :param scope: The scope of the role eligibility request to validate. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + validate. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_validate_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py new file mode 100644 index 000000000000..a7c8473e6d62 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_eligibility_schedules_operations.py @@ -0,0 +1,189 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleEligibilitySchedulesOperations: + """RoleEligibilitySchedulesOperations 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.authorization.v2020_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 + + @distributed_trace_async + async def get( + self, + scope: str, + role_eligibility_schedule_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilitySchedule": + """Get the specified role eligibility schedule for a resource scope. + + :param scope: The scope of the role eligibility schedule. + :type scope: str + :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. + :type role_eligibility_schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilitySchedule, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilitySchedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_eligibility_schedule_name=role_eligibility_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilitySchedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.RoleEligibilityScheduleListResult"]: + """Gets role eligibility schedules for a resource scope. + + :param scope: The scope of the role eligibility schedules. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role + eligibility schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use + $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py new file mode 100644 index 000000000000..e7ad37eb7ead --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policies_operations.py @@ -0,0 +1,296 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_management_policies_operations import build_delete_request, build_get_request, build_list_for_scope_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleManagementPoliciesOperations: + """RoleManagementPoliciesOperations 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.authorization.v2020_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 + + @distributed_trace_async + async def get( + self, + scope: str, + role_management_policy_name: str, + **kwargs: Any + ) -> "_models.RoleManagementPolicy": + """Get the specified role management policy for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to get. + :type role_management_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + scope: str, + role_management_policy_name: str, + parameters: "_models.RoleManagementPolicy", + **kwargs: Any + ) -> "_models.RoleManagementPolicy": + """Update a role management policy. + + :param scope: The scope of the role management policy to upsert. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :type role_management_policy_name: str + :param parameters: Parameters for the role management policy. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicy') + + request = build_update_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_management_policy_name: str, + **kwargs: Any + ) -> None: + """Delete a role management policy. + + :param scope: The scope of the role management policy to upsert. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :type role_management_policy_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_delete_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> AsyncIterable["_models.RoleManagementPolicyListResult"]: + """Gets role management policies for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py new file mode 100644 index 000000000000..8c179e1cf64f --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/aio/operations/_role_management_policy_assignments_operations.py @@ -0,0 +1,299 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._role_management_policy_assignments_operations import build_create_request, build_delete_request, build_get_request, build_list_for_scope_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleManagementPolicyAssignmentsOperations: + """RoleManagementPolicyAssignmentsOperations 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.authorization.v2020_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 + + @distributed_trace_async + async def get( + self, + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any + ) -> "_models.RoleManagementPolicyAssignment": + """Get the specified role management policy assignment for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to get. + :type role_management_policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + scope: str, + role_management_policy_assignment_name: str, + parameters: "_models.RoleManagementPolicyAssignment", + **kwargs: Any + ) -> "_models.RoleManagementPolicyAssignment": + """Create a role management policy assignment. + + :param scope: The scope of the role management policy assignment to upsert. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to upsert. + :type role_management_policy_assignment_name: str + :param parameters: Parameters for the role management policy assignment. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') + + request = build_create_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any + ) -> None: + """Delete a role management policy assignment. + + :param scope: The scope of the role management policy assignment to delete. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to delete. + :type role_management_policy_assignment_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_delete_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> AsyncIterable["_models.RoleManagementPolicyAssignmentListResult"]: + """Gets role management assignment policies for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py new file mode 100644 index 000000000000..f5053e2617e6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/__init__.py @@ -0,0 +1,147 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import ApprovalSettings +from ._models_py3 import ApprovalStage +from ._models_py3 import CloudErrorBody +from ._models_py3 import EligibleChildResource +from ._models_py3 import EligibleChildResourcesListResult +from ._models_py3 import ExpandedProperties +from ._models_py3 import ExpandedPropertiesPrincipal +from ._models_py3 import ExpandedPropertiesRoleDefinition +from ._models_py3 import ExpandedPropertiesScope +from ._models_py3 import Permission +from ._models_py3 import PolicyAssignmentProperties +from ._models_py3 import PolicyAssignmentPropertiesPolicy +from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition +from ._models_py3 import PolicyAssignmentPropertiesScope +from ._models_py3 import PolicyProperties +from ._models_py3 import PolicyPropertiesScope +from ._models_py3 import Principal +from ._models_py3 import RoleAssignmentSchedule +from ._models_py3 import RoleAssignmentScheduleFilter +from ._models_py3 import RoleAssignmentScheduleInstance +from ._models_py3 import RoleAssignmentScheduleInstanceFilter +from ._models_py3 import RoleAssignmentScheduleInstanceListResult +from ._models_py3 import RoleAssignmentScheduleListResult +from ._models_py3 import RoleAssignmentScheduleRequest +from ._models_py3 import RoleAssignmentScheduleRequestFilter +from ._models_py3 import RoleAssignmentScheduleRequestListResult +from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo +from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration +from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo +from ._models_py3 import RoleEligibilitySchedule +from ._models_py3 import RoleEligibilityScheduleFilter +from ._models_py3 import RoleEligibilityScheduleInstance +from ._models_py3 import RoleEligibilityScheduleInstanceFilter +from ._models_py3 import RoleEligibilityScheduleInstanceListResult +from ._models_py3 import RoleEligibilityScheduleListResult +from ._models_py3 import RoleEligibilityScheduleRequest +from ._models_py3 import RoleEligibilityScheduleRequestFilter +from ._models_py3 import RoleEligibilityScheduleRequestListResult +from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo +from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration +from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo +from ._models_py3 import RoleManagementPolicy +from ._models_py3 import RoleManagementPolicyApprovalRule +from ._models_py3 import RoleManagementPolicyAssignment +from ._models_py3 import RoleManagementPolicyAssignmentListResult +from ._models_py3 import RoleManagementPolicyAuthenticationContextRule +from ._models_py3 import RoleManagementPolicyEnablementRule +from ._models_py3 import RoleManagementPolicyExpirationRule +from ._models_py3 import RoleManagementPolicyListResult +from ._models_py3 import RoleManagementPolicyNotificationRule +from ._models_py3 import RoleManagementPolicyRule +from ._models_py3 import RoleManagementPolicyRuleTarget +from ._models_py3 import UserSet + + +from ._authorization_management_client_enums import ( + ApprovalMode, + AssignmentType, + EnablementRules, + MemberType, + NotificationDeliveryMechanism, + NotificationLevel, + PrincipalType, + RecipientType, + RequestType, + RoleManagementPolicyRuleType, + Status, + Type, + UserType, +) + +__all__ = [ + 'ApprovalSettings', + 'ApprovalStage', + 'CloudErrorBody', + 'EligibleChildResource', + 'EligibleChildResourcesListResult', + 'ExpandedProperties', + 'ExpandedPropertiesPrincipal', + 'ExpandedPropertiesRoleDefinition', + 'ExpandedPropertiesScope', + 'Permission', + 'PolicyAssignmentProperties', + 'PolicyAssignmentPropertiesPolicy', + 'PolicyAssignmentPropertiesRoleDefinition', + 'PolicyAssignmentPropertiesScope', + 'PolicyProperties', + 'PolicyPropertiesScope', + 'Principal', + 'RoleAssignmentSchedule', + 'RoleAssignmentScheduleFilter', + 'RoleAssignmentScheduleInstance', + 'RoleAssignmentScheduleInstanceFilter', + 'RoleAssignmentScheduleInstanceListResult', + 'RoleAssignmentScheduleListResult', + 'RoleAssignmentScheduleRequest', + 'RoleAssignmentScheduleRequestFilter', + 'RoleAssignmentScheduleRequestListResult', + 'RoleAssignmentScheduleRequestPropertiesScheduleInfo', + 'RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration', + 'RoleAssignmentScheduleRequestPropertiesTicketInfo', + 'RoleEligibilitySchedule', + 'RoleEligibilityScheduleFilter', + 'RoleEligibilityScheduleInstance', + 'RoleEligibilityScheduleInstanceFilter', + 'RoleEligibilityScheduleInstanceListResult', + 'RoleEligibilityScheduleListResult', + 'RoleEligibilityScheduleRequest', + 'RoleEligibilityScheduleRequestFilter', + 'RoleEligibilityScheduleRequestListResult', + 'RoleEligibilityScheduleRequestPropertiesScheduleInfo', + 'RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration', + 'RoleEligibilityScheduleRequestPropertiesTicketInfo', + 'RoleManagementPolicy', + 'RoleManagementPolicyApprovalRule', + 'RoleManagementPolicyAssignment', + 'RoleManagementPolicyAssignmentListResult', + 'RoleManagementPolicyAuthenticationContextRule', + 'RoleManagementPolicyEnablementRule', + 'RoleManagementPolicyExpirationRule', + 'RoleManagementPolicyListResult', + 'RoleManagementPolicyNotificationRule', + 'RoleManagementPolicyRule', + 'RoleManagementPolicyRuleTarget', + 'UserSet', + 'ApprovalMode', + 'AssignmentType', + 'EnablementRules', + 'MemberType', + 'NotificationDeliveryMechanism', + 'NotificationLevel', + 'PrincipalType', + 'RecipientType', + 'RequestType', + 'RoleManagementPolicyRuleType', + 'Status', + 'Type', + 'UserType', +] diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py new file mode 100644 index 000000000000..6fd37c6649ad --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_authorization_management_client_enums.py @@ -0,0 +1,142 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class ApprovalMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of rule + """ + + SINGLE_STAGE = "SingleStage" + SERIAL = "Serial" + PARALLEL = "Parallel" + NO_APPROVAL = "NoApproval" + +class AssignmentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Assignment type of the role assignment schedule + """ + + ACTIVATED = "Activated" + ASSIGNED = "Assigned" + +class EnablementRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of enablement rule + """ + + MULTI_FACTOR_AUTHENTICATION = "MultiFactorAuthentication" + JUSTIFICATION = "Justification" + TICKETING = "Ticketing" + +class MemberType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Membership type of the role assignment schedule + """ + + INHERITED = "Inherited" + DIRECT = "Direct" + GROUP = "Group" + +class NotificationDeliveryMechanism(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of notification. + """ + + EMAIL = "Email" + +class NotificationLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The notification level. + """ + + NONE = "None" + CRITICAL = "Critical" + ALL = "All" + +class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The principal type of the assigned principal ID. + """ + + USER = "User" + GROUP = "Group" + SERVICE_PRINCIPAL = "ServicePrincipal" + FOREIGN_GROUP = "ForeignGroup" + DEVICE = "Device" + +class RecipientType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The recipient type. + """ + + REQUESTOR = "Requestor" + APPROVER = "Approver" + ADMIN = "Admin" + +class RequestType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc + """ + + ADMIN_ASSIGN = "AdminAssign" + ADMIN_REMOVE = "AdminRemove" + ADMIN_UPDATE = "AdminUpdate" + ADMIN_EXTEND = "AdminExtend" + ADMIN_RENEW = "AdminRenew" + SELF_ACTIVATE = "SelfActivate" + SELF_DEACTIVATE = "SelfDeactivate" + SELF_EXTEND = "SelfExtend" + SELF_RENEW = "SelfRenew" + +class RoleManagementPolicyRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of rule + """ + + ROLE_MANAGEMENT_POLICY_APPROVAL_RULE = "RoleManagementPolicyApprovalRule" + ROLE_MANAGEMENT_POLICY_AUTHENTICATION_CONTEXT_RULE = "RoleManagementPolicyAuthenticationContextRule" + ROLE_MANAGEMENT_POLICY_ENABLEMENT_RULE = "RoleManagementPolicyEnablementRule" + ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" + ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" + +class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The status of the role assignment schedule. + """ + + ACCEPTED = "Accepted" + PENDING_EVALUATION = "PendingEvaluation" + GRANTED = "Granted" + DENIED = "Denied" + PENDING_PROVISIONING = "PendingProvisioning" + PROVISIONED = "Provisioned" + PENDING_REVOCATION = "PendingRevocation" + REVOKED = "Revoked" + CANCELED = "Canceled" + FAILED = "Failed" + PENDING_APPROVAL_PROVISIONING = "PendingApprovalProvisioning" + PENDING_APPROVAL = "PendingApproval" + FAILED_AS_RESOURCE_IS_LOCKED = "FailedAsResourceIsLocked" + PENDING_ADMIN_DECISION = "PendingAdminDecision" + ADMIN_APPROVED = "AdminApproved" + ADMIN_DENIED = "AdminDenied" + TIMED_OUT = "TimedOut" + PROVISIONING_STARTED = "ProvisioningStarted" + INVALID = "Invalid" + PENDING_SCHEDULE_CREATION = "PendingScheduleCreation" + SCHEDULE_CREATED = "ScheduleCreated" + PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" + +class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Type of the role assignment schedule expiration + """ + + AFTER_DURATION = "AfterDuration" + AFTER_DATE_TIME = "AfterDateTime" + NO_EXPIRATION = "NoExpiration" + +class UserType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of user. + """ + + USER = "User" + GROUP = "Group" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py new file mode 100644 index 000000000000..9a6179e00988 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/models/_models_py3.py @@ -0,0 +1,3119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 datetime +from typing import List, Optional, Union + +import msrest.serialization + +from ._authorization_management_client_enums import * + + +class ApprovalSettings(msrest.serialization.Model): + """The approval settings. + + :ivar is_approval_required: Determines whether approval is required or not. + :vartype is_approval_required: bool + :ivar is_approval_required_for_extension: Determines whether approval is required for + assignment extension. + :vartype is_approval_required_for_extension: bool + :ivar is_requestor_justification_required: Determine whether requestor justification is + required. + :vartype is_requestor_justification_required: bool + :ivar approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", + "Parallel", "NoApproval". + :vartype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01.models.ApprovalMode + :ivar approval_stages: The approval stages of the request. + :vartype approval_stages: list[~azure.mgmt.authorization.v2020_10_01.models.ApprovalStage] + """ + + _attribute_map = { + 'is_approval_required': {'key': 'isApprovalRequired', 'type': 'bool'}, + 'is_approval_required_for_extension': {'key': 'isApprovalRequiredForExtension', 'type': 'bool'}, + 'is_requestor_justification_required': {'key': 'isRequestorJustificationRequired', 'type': 'bool'}, + 'approval_mode': {'key': 'approvalMode', 'type': 'str'}, + 'approval_stages': {'key': 'approvalStages', 'type': '[ApprovalStage]'}, + } + + def __init__( + self, + *, + is_approval_required: Optional[bool] = None, + is_approval_required_for_extension: Optional[bool] = None, + is_requestor_justification_required: Optional[bool] = None, + approval_mode: Optional[Union[str, "ApprovalMode"]] = None, + approval_stages: Optional[List["ApprovalStage"]] = None, + **kwargs + ): + """ + :keyword is_approval_required: Determines whether approval is required or not. + :paramtype is_approval_required: bool + :keyword is_approval_required_for_extension: Determines whether approval is required for + assignment extension. + :paramtype is_approval_required_for_extension: bool + :keyword is_requestor_justification_required: Determine whether requestor justification is + required. + :paramtype is_requestor_justification_required: bool + :keyword approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", + "Parallel", "NoApproval". + :paramtype approval_mode: str or ~azure.mgmt.authorization.v2020_10_01.models.ApprovalMode + :keyword approval_stages: The approval stages of the request. + :paramtype approval_stages: list[~azure.mgmt.authorization.v2020_10_01.models.ApprovalStage] + """ + super(ApprovalSettings, self).__init__(**kwargs) + self.is_approval_required = is_approval_required + self.is_approval_required_for_extension = is_approval_required_for_extension + self.is_requestor_justification_required = is_requestor_justification_required + self.approval_mode = approval_mode + self.approval_stages = approval_stages + + +class ApprovalStage(msrest.serialization.Model): + """The approval stage. + + :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed + out. + :vartype approval_stage_time_out_in_days: int + :ivar is_approver_justification_required: Determines whether approver need to provide + justification for his decision. + :vartype is_approver_justification_required: bool + :ivar escalation_time_in_minutes: The time in minutes when the approval request would be + escalated if the primary approver does not approve. + :vartype escalation_time_in_minutes: int + :ivar primary_approvers: The primary approver of the request. + :vartype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] + :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. + :vartype is_escalation_enabled: bool + :ivar escalation_approvers: The escalation approver of the request. + :vartype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] + """ + + _attribute_map = { + 'approval_stage_time_out_in_days': {'key': 'approvalStageTimeOutInDays', 'type': 'int'}, + 'is_approver_justification_required': {'key': 'isApproverJustificationRequired', 'type': 'bool'}, + 'escalation_time_in_minutes': {'key': 'escalationTimeInMinutes', 'type': 'int'}, + 'primary_approvers': {'key': 'primaryApprovers', 'type': '[UserSet]'}, + 'is_escalation_enabled': {'key': 'isEscalationEnabled', 'type': 'bool'}, + 'escalation_approvers': {'key': 'escalationApprovers', 'type': '[UserSet]'}, + } + + def __init__( + self, + *, + approval_stage_time_out_in_days: Optional[int] = None, + is_approver_justification_required: Optional[bool] = None, + escalation_time_in_minutes: Optional[int] = None, + primary_approvers: Optional[List["UserSet"]] = None, + is_escalation_enabled: Optional[bool] = None, + escalation_approvers: Optional[List["UserSet"]] = None, + **kwargs + ): + """ + :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed + out. + :paramtype approval_stage_time_out_in_days: int + :keyword is_approver_justification_required: Determines whether approver need to provide + justification for his decision. + :paramtype is_approver_justification_required: bool + :keyword escalation_time_in_minutes: The time in minutes when the approval request would be + escalated if the primary approver does not approve. + :paramtype escalation_time_in_minutes: int + :keyword primary_approvers: The primary approver of the request. + :paramtype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] + :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. + :paramtype is_escalation_enabled: bool + :keyword escalation_approvers: The escalation approver of the request. + :paramtype escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01.models.UserSet] + """ + super(ApprovalStage, self).__init__(**kwargs) + self.approval_stage_time_out_in_days = approval_stage_time_out_in_days + self.is_approver_justification_required = is_approver_justification_required + self.escalation_time_in_minutes = escalation_time_in_minutes + self.primary_approvers = primary_approvers + self.is_escalation_enabled = is_escalation_enabled + self.escalation_approvers = escalation_approvers + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + + +class EligibleChildResource(msrest.serialization.Model): + """Eligible child resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The resource scope Id. + :vartype id: str + :ivar name: The resource name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(EligibleChildResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class EligibleChildResourcesListResult(msrest.serialization.Model): + """Eligible child resources list operation result. + + :ivar value: Eligible child resource list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[EligibleChildResource]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["EligibleChildResource"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Eligible child resource list. + :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(EligibleChildResourcesListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ExpandedProperties(msrest.serialization.Model): + """ExpandedProperties. + + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesScope + :ivar role_definition: Details of role definition. + :vartype role_definition: + ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesRoleDefinition + :ivar principal: Details of the principal. + :vartype principal: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesPrincipal + """ + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'ExpandedPropertiesScope'}, + 'role_definition': {'key': 'roleDefinition', 'type': 'ExpandedPropertiesRoleDefinition'}, + 'principal': {'key': 'principal', 'type': 'ExpandedPropertiesPrincipal'}, + } + + def __init__( + self, + *, + scope: Optional["ExpandedPropertiesScope"] = None, + role_definition: Optional["ExpandedPropertiesRoleDefinition"] = None, + principal: Optional["ExpandedPropertiesPrincipal"] = None, + **kwargs + ): + """ + :keyword scope: Details of the resource scope. + :paramtype scope: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesScope + :keyword role_definition: Details of role definition. + :paramtype role_definition: + ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesRoleDefinition + :keyword principal: Details of the principal. + :paramtype principal: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedPropertiesPrincipal + """ + super(ExpandedProperties, self).__init__(**kwargs) + self.scope = scope + self.role_definition = role_definition + self.principal = principal + + +class ExpandedPropertiesPrincipal(msrest.serialization.Model): + """Details of the principal. + + :ivar id: Id of the principal. + :vartype id: str + :ivar display_name: Display name of the principal. + :vartype display_name: str + :ivar email: Email id of the principal. + :vartype email: str + :ivar type: Type of the principal. + :vartype type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + email: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Id of the principal. + :paramtype id: str + :keyword display_name: Display name of the principal. + :paramtype display_name: str + :keyword email: Email id of the principal. + :paramtype email: str + :keyword type: Type of the principal. + :paramtype type: str + """ + super(ExpandedPropertiesPrincipal, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.email = email + self.type = type + + +class ExpandedPropertiesRoleDefinition(msrest.serialization.Model): + """Details of role definition. + + :ivar id: Id of the role definition. + :vartype id: str + :ivar display_name: Display name of the role definition. + :vartype display_name: str + :ivar type: Type of the role definition. + :vartype type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Id of the role definition. + :paramtype id: str + :keyword display_name: Display name of the role definition. + :paramtype display_name: str + :keyword type: Type of the role definition. + :paramtype type: str + """ + super(ExpandedPropertiesRoleDefinition, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class ExpandedPropertiesScope(msrest.serialization.Model): + """Details of the resource scope. + + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ + super(ExpandedPropertiesScope, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class Permission(msrest.serialization.Model): + """Role definition permissions. + + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] + """ + + _attribute_map = { + 'actions': {'key': 'actions', 'type': '[str]'}, + 'not_actions': {'key': 'notActions', 'type': '[str]'}, + 'data_actions': {'key': 'dataActions', 'type': '[str]'}, + 'not_data_actions': {'key': 'notDataActions', 'type': '[str]'}, + } + + def __init__( + self, + *, + actions: Optional[List[str]] = None, + not_actions: Optional[List[str]] = None, + data_actions: Optional[List[str]] = None, + not_data_actions: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + :keyword data_actions: Allowed Data actions. + :paramtype data_actions: list[str] + :keyword not_data_actions: Denied Data actions. + :paramtype not_data_actions: list[str] + """ + super(Permission, self).__init__(**kwargs) + self.actions = actions + self.not_actions = not_actions + self.data_actions = data_actions + self.not_data_actions = not_data_actions + + +class PolicyAssignmentProperties(msrest.serialization.Model): + """Expanded info of resource scope, role definition and policy. + + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesScope + :ivar role_definition: Details of role definition. + :vartype role_definition: + ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesRoleDefinition + :ivar policy: Details of the policy. + :vartype policy: ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesPolicy + """ + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'PolicyAssignmentPropertiesScope'}, + 'role_definition': {'key': 'roleDefinition', 'type': 'PolicyAssignmentPropertiesRoleDefinition'}, + 'policy': {'key': 'policy', 'type': 'PolicyAssignmentPropertiesPolicy'}, + } + + def __init__( + self, + *, + scope: Optional["PolicyAssignmentPropertiesScope"] = None, + role_definition: Optional["PolicyAssignmentPropertiesRoleDefinition"] = None, + policy: Optional["PolicyAssignmentPropertiesPolicy"] = None, + **kwargs + ): + """ + :keyword scope: Details of the resource scope. + :paramtype scope: ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesScope + :keyword role_definition: Details of role definition. + :paramtype role_definition: + ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesRoleDefinition + :keyword policy: Details of the policy. + :paramtype policy: + ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentPropertiesPolicy + """ + super(PolicyAssignmentProperties, self).__init__(**kwargs) + self.scope = scope + self.role_definition = role_definition + self.policy = policy + + +class PolicyAssignmentPropertiesPolicy(msrest.serialization.Model): + """Details of the policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Id of the policy. + :vartype id: str + :ivar last_modified_by: The name of the entity last modified it. + :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01.models.Principal + :ivar last_modified_date_time: The last modified date time. + :vartype last_modified_date_time: ~datetime.datetime + """ + + _validation = { + 'last_modified_by': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'Principal'}, + 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + last_modified_date_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword id: Id of the policy. + :paramtype id: str + :keyword last_modified_date_time: The last modified date time. + :paramtype last_modified_date_time: ~datetime.datetime + """ + super(PolicyAssignmentPropertiesPolicy, self).__init__(**kwargs) + self.id = id + self.last_modified_by = None + self.last_modified_date_time = last_modified_date_time + + +class PolicyAssignmentPropertiesRoleDefinition(msrest.serialization.Model): + """Details of role definition. + + :ivar id: Id of the role definition. + :vartype id: str + :ivar display_name: Display name of the role definition. + :vartype display_name: str + :ivar type: Type of the role definition. + :vartype type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Id of the role definition. + :paramtype id: str + :keyword display_name: Display name of the role definition. + :paramtype display_name: str + :keyword type: Type of the role definition. + :paramtype type: str + """ + super(PolicyAssignmentPropertiesRoleDefinition, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class PolicyAssignmentPropertiesScope(msrest.serialization.Model): + """Details of the resource scope. + + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ + super(PolicyAssignmentPropertiesScope, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class PolicyProperties(msrest.serialization.Model): + """Expanded info of resource scope. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.v2020_10_01.models.PolicyPropertiesScope + """ + + _validation = { + 'scope': {'readonly': True}, + } + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'PolicyPropertiesScope'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(PolicyProperties, self).__init__(**kwargs) + self.scope = None + + +class PolicyPropertiesScope(msrest.serialization.Model): + """Details of the resource scope. + + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ + super(PolicyPropertiesScope, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + + +class Principal(msrest.serialization.Model): + """The name of the entity last modified it. + + :ivar id: The id of the principal made changes. + :vartype id: str + :ivar display_name: The name of the principal made changes. + :vartype display_name: str + :ivar type: Type of principal such as user , group etc. + :vartype type: str + :ivar email: Email of principal. + :vartype email: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'email': {'key': 'email', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + display_name: Optional[str] = None, + type: Optional[str] = None, + email: Optional[str] = None, + **kwargs + ): + """ + :keyword id: The id of the principal made changes. + :paramtype id: str + :keyword display_name: The name of the principal made changes. + :paramtype display_name: str + :keyword type: Type of principal such as user , group etc. + :paramtype type: str + :keyword email: Email of principal. + :paramtype email: str + """ + super(Principal, self).__init__(**kwargs) + self.id = id + self.display_name = display_name + self.type = type + self.email = email + + +class RoleAssignmentSchedule(msrest.serialization.Model): + """Role Assignment schedule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment schedule Id. + :vartype id: str + :ivar name: The role assignment schedule name. + :vartype name: str + :ivar type: The role assignment schedule type. + :vartype type: str + :ivar scope: The role assignment schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + create this roleAssignmentSchedule. + :vartype role_assignment_schedule_request_id: str + :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated + this roleAssignmentSchedule. + :vartype linked_role_eligibility_schedule_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Possible values + include: "Activated", "Assigned". + :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType + :ivar member_type: Membership type of the role assignment schedule. Possible values include: + "Inherited", "Direct", "Group". + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :ivar status: The status of the role assignment schedule. Possible values include: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :ivar start_date_time: Start DateTime when role assignment schedule. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: End DateTime when role assignment schedule. + :vartype end_date_time: ~datetime.datetime + :ivar condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: DateTime when role assignment schedule was modified. + :vartype updated_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, + 'role_assignment_schedule_request_id': {'key': 'properties.roleAssignmentScheduleRequestId', 'type': 'str'}, + 'linked_role_eligibility_schedule_id': {'key': 'properties.linkedRoleEligibilityScheduleId', 'type': 'str'}, + 'assignment_type': {'key': 'properties.assignmentType', 'type': 'str'}, + 'member_type': {'key': 'properties.memberType', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, + 'condition': {'key': 'properties.condition', 'type': 'str'}, + 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, + 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "PrincipalType"]] = None, + role_assignment_schedule_request_id: Optional[str] = None, + linked_role_eligibility_schedule_id: Optional[str] = None, + assignment_type: Optional[Union[str, "AssignmentType"]] = None, + member_type: Optional[Union[str, "MemberType"]] = None, + status: Optional[Union[str, "Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + updated_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["ExpandedProperties"] = None, + **kwargs + ): + """ + :keyword scope: The role assignment schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + create this roleAssignmentSchedule. + :paramtype role_assignment_schedule_request_id: str + :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to + activated this roleAssignmentSchedule. + :paramtype linked_role_eligibility_schedule_id: str + :keyword assignment_type: Assignment type of the role assignment schedule. Possible values + include: "Activated", "Assigned". + :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType + :keyword member_type: Membership type of the role assignment schedule. Possible values include: + "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :keyword status: The status of the role assignment schedule. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :keyword start_date_time: Start DateTime when role assignment schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: End DateTime when role assignment schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role assignment schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: DateTime when role assignment schedule was modified. + :paramtype updated_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + super(RoleAssignmentSchedule, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_assignment_schedule_request_id = role_assignment_schedule_request_id + self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id + self.assignment_type = assignment_type + self.member_type = member_type + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.updated_on = updated_on + self.expanded_properties = expanded_properties + + +class RoleAssignmentScheduleFilter(msrest.serialization.Model): + """Role assignment schedule filter. + + :ivar principal_id: Returns role assignment schedule of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment schedule of the specific role definition. + :vartype role_definition_id: str + :ivar status: Returns role assignment schedule instances of the specific status. + :vartype status: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Returns role assignment schedule of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment schedule of the specific role definition. + :paramtype role_definition_id: str + :keyword status: Returns role assignment schedule instances of the specific status. + :paramtype status: str + """ + super(RoleAssignmentScheduleFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + + +class RoleAssignmentScheduleInstance(msrest.serialization.Model): + """Information about current or upcoming role assignment schedule instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment schedule instance ID. + :vartype id: str + :ivar name: The role assignment schedule instance name. + :vartype name: str + :ivar type: The role assignment schedule instance type. + :vartype type: str + :ivar scope: The role assignment schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :ivar role_assignment_schedule_id: Id of the master role assignment schedule. + :vartype role_assignment_schedule_id: str + :ivar origin_role_assignment_id: Role Assignment Id in external system. + :vartype origin_role_assignment_id: str + :ivar status: The status of the role assignment schedule instance. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :ivar start_date_time: The startDateTime of the role assignment schedule instance. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The endDateTime of the role assignment schedule instance. + :vartype end_date_time: ~datetime.datetime + :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. + :vartype linked_role_eligibility_schedule_id: str + :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to + this roleAssignmentScheduleInstance. + :vartype linked_role_eligibility_schedule_instance_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Possible values + include: "Activated", "Assigned". + :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType + :ivar member_type: Membership type of the role assignment schedule. Possible values include: + "Inherited", "Direct", "Group". + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :ivar condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule was created. + :vartype created_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, + 'role_assignment_schedule_id': {'key': 'properties.roleAssignmentScheduleId', 'type': 'str'}, + 'origin_role_assignment_id': {'key': 'properties.originRoleAssignmentId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, + 'linked_role_eligibility_schedule_id': {'key': 'properties.linkedRoleEligibilityScheduleId', 'type': 'str'}, + 'linked_role_eligibility_schedule_instance_id': {'key': 'properties.linkedRoleEligibilityScheduleInstanceId', 'type': 'str'}, + 'assignment_type': {'key': 'properties.assignmentType', 'type': 'str'}, + 'member_type': {'key': 'properties.memberType', 'type': 'str'}, + 'condition': {'key': 'properties.condition', 'type': 'str'}, + 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "PrincipalType"]] = None, + role_assignment_schedule_id: Optional[str] = None, + origin_role_assignment_id: Optional[str] = None, + status: Optional[Union[str, "Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + linked_role_eligibility_schedule_id: Optional[str] = None, + linked_role_eligibility_schedule_instance_id: Optional[str] = None, + assignment_type: Optional[Union[str, "AssignmentType"]] = None, + member_type: Optional[Union[str, "MemberType"]] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["ExpandedProperties"] = None, + **kwargs + ): + """ + :keyword scope: The role assignment schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :keyword role_assignment_schedule_id: Id of the master role assignment schedule. + :paramtype role_assignment_schedule_id: str + :keyword origin_role_assignment_id: Role Assignment Id in external system. + :paramtype origin_role_assignment_id: str + :keyword status: The status of the role assignment schedule instance. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :keyword start_date_time: The startDateTime of the role assignment schedule instance. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The endDateTime of the role assignment schedule instance. + :paramtype end_date_time: ~datetime.datetime + :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. + :paramtype linked_role_eligibility_schedule_id: str + :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked + to this roleAssignmentScheduleInstance. + :paramtype linked_role_eligibility_schedule_instance_id: str + :keyword assignment_type: Assignment type of the role assignment schedule. Possible values + include: "Activated", "Assigned". + :paramtype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01.models.AssignmentType + :keyword member_type: Membership type of the role assignment schedule. Possible values include: + "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role assignment schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + super(RoleAssignmentScheduleInstance, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_assignment_schedule_id = role_assignment_schedule_id + self.origin_role_assignment_id = origin_role_assignment_id + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id + self.linked_role_eligibility_schedule_instance_id = linked_role_eligibility_schedule_instance_id + self.assignment_type = assignment_type + self.member_type = member_type + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.expanded_properties = expanded_properties + + +class RoleAssignmentScheduleInstanceFilter(msrest.serialization.Model): + """Role assignment schedule instance filter. + + :ivar principal_id: Returns role assignment schedule instances of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment schedule instances of the specific role + definition. + :vartype role_definition_id: str + :ivar status: Returns role assignment schedule instances of the specific status. + :vartype status: str + :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + specific role assignment schedule. + :vartype role_assignment_schedule_id: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'role_assignment_schedule_id': {'key': 'roleAssignmentScheduleId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + role_assignment_schedule_id: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Returns role assignment schedule instances of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment schedule instances of the specific role + definition. + :paramtype role_definition_id: str + :keyword status: Returns role assignment schedule instances of the specific status. + :paramtype status: str + :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + specific role assignment schedule. + :paramtype role_assignment_schedule_id: str + """ + super(RoleAssignmentScheduleInstanceFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + self.role_assignment_schedule_id = role_assignment_schedule_id + + +class RoleAssignmentScheduleInstanceListResult(msrest.serialization.Model): + """Role assignment schedule instance list operation result. + + :ivar value: Role assignment schedule instance list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleAssignmentScheduleInstance]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleAssignmentScheduleInstance"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role assignment schedule instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleAssignmentScheduleInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleListResult(msrest.serialization.Model): + """Role assignment schedule list operation result. + + :ivar value: Role assignment schedule list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleAssignmentSchedule]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleAssignmentSchedule"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role assignment schedule list. + :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleAssignmentScheduleListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleRequest(msrest.serialization.Model): + """Role Assignment schedule request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role assignment schedule request ID. + :vartype id: str + :ivar name: The role assignment schedule request name. + :vartype name: str + :ivar type: The role assignment schedule request type. + :vartype type: str + :ivar scope: The role assignment schedule request scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", + "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". + :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType + :ivar status: The status of the role assignment schedule request. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :ivar approval_id: The approvalId of the role assignment schedule request. + :vartype approval_id: str + :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role + assignment schedule id being updated. + :vartype target_role_assignment_schedule_id: str + :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id + being updated. + :vartype target_role_assignment_schedule_instance_id: str + :ivar schedule_info: Schedule info of the role assignment schedule. + :vartype schedule_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo + :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + activate an eligibility. + :vartype linked_role_eligibility_schedule_id: str + :ivar justification: Justification for the role assignment. + :vartype justification: str + :ivar ticket_info: Ticket Info of the role assignment. + :vartype ticket_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesTicketInfo + :ivar condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule request was created. + :vartype created_on: ~datetime.datetime + :ivar requestor_id: Id of the user who created this request. + :vartype requestor_id: str + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'scope': {'readonly': True}, + 'principal_type': {'readonly': True}, + 'status': {'readonly': True}, + 'approval_id': {'readonly': True}, + 'created_on': {'readonly': True}, + 'requestor_id': {'readonly': True}, + 'expanded_properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, + 'request_type': {'key': 'properties.requestType', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'approval_id': {'key': 'properties.approvalId', 'type': 'str'}, + 'target_role_assignment_schedule_id': {'key': 'properties.targetRoleAssignmentScheduleId', 'type': 'str'}, + 'target_role_assignment_schedule_instance_id': {'key': 'properties.targetRoleAssignmentScheduleInstanceId', 'type': 'str'}, + 'schedule_info': {'key': 'properties.scheduleInfo', 'type': 'RoleAssignmentScheduleRequestPropertiesScheduleInfo'}, + 'linked_role_eligibility_schedule_id': {'key': 'properties.linkedRoleEligibilityScheduleId', 'type': 'str'}, + 'justification': {'key': 'properties.justification', 'type': 'str'}, + 'ticket_info': {'key': 'properties.ticketInfo', 'type': 'RoleAssignmentScheduleRequestPropertiesTicketInfo'}, + 'condition': {'key': 'properties.condition', 'type': 'str'}, + 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'requestor_id': {'key': 'properties.requestorId', 'type': 'str'}, + 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, + } + + def __init__( + self, + *, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + request_type: Optional[Union[str, "RequestType"]] = None, + target_role_assignment_schedule_id: Optional[str] = None, + target_role_assignment_schedule_instance_id: Optional[str] = None, + schedule_info: Optional["RoleAssignmentScheduleRequestPropertiesScheduleInfo"] = None, + linked_role_eligibility_schedule_id: Optional[str] = None, + justification: Optional[str] = None, + ticket_info: Optional["RoleAssignmentScheduleRequestPropertiesTicketInfo"] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + **kwargs + ): + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", + "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". + :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType + :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the + role assignment schedule id being updated. + :paramtype target_role_assignment_schedule_id: str + :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id + being updated. + :paramtype target_role_assignment_schedule_instance_id: str + :keyword schedule_info: Schedule info of the role assignment schedule. + :paramtype schedule_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo + :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + activate an eligibility. + :paramtype linked_role_eligibility_schedule_id: str + :keyword justification: Justification for the role assignment. + :paramtype justification: str + :keyword ticket_info: Ticket Info of the role assignment. + :paramtype ticket_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesTicketInfo + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + """ + super(RoleAssignmentScheduleRequest, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = None + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = None + self.request_type = request_type + self.status = None + self.approval_id = None + self.target_role_assignment_schedule_id = target_role_assignment_schedule_id + self.target_role_assignment_schedule_instance_id = target_role_assignment_schedule_instance_id + self.schedule_info = schedule_info + self.linked_role_eligibility_schedule_id = linked_role_eligibility_schedule_id + self.justification = justification + self.ticket_info = ticket_info + self.condition = condition + self.condition_version = condition_version + self.created_on = None + self.requestor_id = None + self.expanded_properties = None + + +class RoleAssignmentScheduleRequestFilter(msrest.serialization.Model): + """Role assignment schedule request filter. + + :ivar principal_id: Returns role assignment requests of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment requests of the specific role definition. + :vartype role_definition_id: str + :ivar requestor_id: Returns role assignment requests created by specific principal. + :vartype requestor_id: str + :ivar status: Returns role assignment requests of specific status. + :vartype status: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + requestor_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Returns role assignment requests of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment requests of the specific role definition. + :paramtype role_definition_id: str + :keyword requestor_id: Returns role assignment requests created by specific principal. + :paramtype requestor_id: str + :keyword status: Returns role assignment requests of specific status. + :paramtype status: str + """ + super(RoleAssignmentScheduleRequestFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.requestor_id = requestor_id + self.status = status + + +class RoleAssignmentScheduleRequestListResult(msrest.serialization.Model): + """Role assignment schedule request list operation result. + + :ivar value: Role assignment schedule request list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleAssignmentScheduleRequest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleAssignmentScheduleRequest"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role assignment schedule request list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleAssignmentScheduleRequestListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleAssignmentScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): + """Schedule info of the role assignment schedule. + + :ivar start_date_time: Start DateTime of the role assignment schedule. + :vartype start_date_time: ~datetime.datetime + :ivar expiration: Expiration of the role assignment schedule. + :vartype expiration: + ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + """ + + _attribute_map = { + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'expiration': {'key': 'expiration', 'type': 'RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration'}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + expiration: Optional["RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, + **kwargs + ): + """ + :keyword start_date_time: Start DateTime of the role assignment schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword expiration: Expiration of the role assignment schedule. + :paramtype expiration: + ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + """ + super(RoleAssignmentScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) + self.start_date_time = start_date_time + self.expiration = expiration + + +class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): + """Expiration of the role assignment schedule. + + :ivar type: Type of the role assignment schedule expiration. Possible values include: + "AfterDuration", "AfterDateTime", "NoExpiration". + :vartype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type + :ivar end_date_time: End DateTime of the role assignment schedule. + :vartype end_date_time: ~datetime.datetime + :ivar duration: Duration of the role assignment schedule in TimeSpan. + :vartype duration: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'end_date_time': {'key': 'endDateTime', 'type': 'iso-8601'}, + 'duration': {'key': 'duration', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "Type"]] = None, + end_date_time: Optional[datetime.datetime] = None, + duration: Optional[str] = None, + **kwargs + ): + """ + :keyword type: Type of the role assignment schedule expiration. Possible values include: + "AfterDuration", "AfterDateTime", "NoExpiration". + :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type + :keyword end_date_time: End DateTime of the role assignment schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword duration: Duration of the role assignment schedule in TimeSpan. + :paramtype duration: str + """ + super(RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) + self.type = type + self.end_date_time = end_date_time + self.duration = duration + + +class RoleAssignmentScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): + """Ticket Info of the role assignment. + + :ivar ticket_number: Ticket number for the role assignment. + :vartype ticket_number: str + :ivar ticket_system: Ticket system name for the role assignment. + :vartype ticket_system: str + """ + + _attribute_map = { + 'ticket_number': {'key': 'ticketNumber', 'type': 'str'}, + 'ticket_system': {'key': 'ticketSystem', 'type': 'str'}, + } + + def __init__( + self, + *, + ticket_number: Optional[str] = None, + ticket_system: Optional[str] = None, + **kwargs + ): + """ + :keyword ticket_number: Ticket number for the role assignment. + :paramtype ticket_number: str + :keyword ticket_system: Ticket system name for the role assignment. + :paramtype ticket_system: str + """ + super(RoleAssignmentScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_system = ticket_system + + +class RoleEligibilitySchedule(msrest.serialization.Model): + """Role eligibility schedule. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role eligibility schedule Id. + :vartype id: str + :ivar name: The role eligibility schedule name. + :vartype name: str + :ivar type: The role eligibility schedule type. + :vartype type: str + :ivar scope: The role eligibility schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + create this roleAssignmentSchedule. + :vartype role_eligibility_schedule_request_id: str + :ivar member_type: Membership type of the role eligibility schedule. Possible values include: + "Inherited", "Direct", "Group". + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :ivar status: The status of the role eligibility schedule. Possible values include: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :ivar start_date_time: Start DateTime when role eligibility schedule. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: End DateTime when role eligibility schedule. + :vartype end_date_time: ~datetime.datetime + :ivar condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: DateTime when role eligibility schedule was modified. + :vartype updated_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, + 'role_eligibility_schedule_request_id': {'key': 'properties.roleEligibilityScheduleRequestId', 'type': 'str'}, + 'member_type': {'key': 'properties.memberType', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, + 'condition': {'key': 'properties.condition', 'type': 'str'}, + 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, + 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "PrincipalType"]] = None, + role_eligibility_schedule_request_id: Optional[str] = None, + member_type: Optional[Union[str, "MemberType"]] = None, + status: Optional[Union[str, "Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + updated_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["ExpandedProperties"] = None, + **kwargs + ): + """ + :keyword scope: The role eligibility schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + create this roleAssignmentSchedule. + :paramtype role_eligibility_schedule_request_id: str + :keyword member_type: Membership type of the role eligibility schedule. Possible values + include: "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :keyword status: The status of the role eligibility schedule. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :keyword start_date_time: Start DateTime when role eligibility schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: End DateTime when role eligibility schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role eligibility schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: DateTime when role eligibility schedule was modified. + :paramtype updated_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + super(RoleEligibilitySchedule, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_eligibility_schedule_request_id = role_eligibility_schedule_request_id + self.member_type = member_type + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.updated_on = updated_on + self.expanded_properties = expanded_properties + + +class RoleEligibilityScheduleFilter(msrest.serialization.Model): + """Role eligibility schedule filter. + + :ivar principal_id: Returns role eligibility schedule of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. + :vartype role_definition_id: str + :ivar status: Returns role eligibility schedule of the specific status. + :vartype status: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Returns role eligibility schedule of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. + :paramtype role_definition_id: str + :keyword status: Returns role eligibility schedule of the specific status. + :paramtype status: str + """ + super(RoleEligibilityScheduleFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + + +class RoleEligibilityScheduleInstance(msrest.serialization.Model): + """Information about current or upcoming role eligibility schedule instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role eligibility schedule instance ID. + :vartype id: str + :ivar name: The role eligibility schedule instance name. + :vartype name: str + :ivar type: The role eligibility schedule instance type. + :vartype type: str + :ivar scope: The role eligibility schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. + :vartype role_eligibility_schedule_id: str + :ivar status: The status of the role eligibility schedule instance. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :ivar start_date_time: The startDateTime of the role eligibility schedule instance. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The endDateTime of the role eligibility schedule instance. + :vartype end_date_time: ~datetime.datetime + :ivar member_type: Membership type of the role eligibility schedule. Possible values include: + "Inherited", "Direct", "Group". + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :ivar condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule was created. + :vartype created_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, + 'role_eligibility_schedule_id': {'key': 'properties.roleEligibilityScheduleId', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, + 'member_type': {'key': 'properties.memberType', 'type': 'str'}, + 'condition': {'key': 'properties.condition', 'type': 'str'}, + 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + principal_type: Optional[Union[str, "PrincipalType"]] = None, + role_eligibility_schedule_id: Optional[str] = None, + status: Optional[Union[str, "Status"]] = None, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + member_type: Optional[Union[str, "MemberType"]] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + created_on: Optional[datetime.datetime] = None, + expanded_properties: Optional["ExpandedProperties"] = None, + **kwargs + ): + """ + :keyword scope: The role eligibility schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. + :paramtype role_eligibility_schedule_id: str + :keyword status: The status of the role eligibility schedule instance. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :keyword start_date_time: The startDateTime of the role eligibility schedule instance. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The endDateTime of the role eligibility schedule instance. + :paramtype end_date_time: ~datetime.datetime + :keyword member_type: Membership type of the role eligibility schedule. Possible values + include: "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01.models.MemberType + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role eligibility schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + super(RoleEligibilityScheduleInstance, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = scope + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = principal_type + self.role_eligibility_schedule_id = role_eligibility_schedule_id + self.status = status + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.member_type = member_type + self.condition = condition + self.condition_version = condition_version + self.created_on = created_on + self.expanded_properties = expanded_properties + + +class RoleEligibilityScheduleInstanceFilter(msrest.serialization.Model): + """Role eligibility schedule instance filter. + + :ivar principal_id: Returns role eligibility schedule instances of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility schedule instances of the specific role + definition. + :vartype role_definition_id: str + :ivar status: Returns role eligibility schedule instances of the specific status. + :vartype status: str + :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a + specific role eligibility schedule. + :vartype role_eligibility_schedule_id: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'role_eligibility_schedule_id': {'key': 'roleEligibilityScheduleId', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + status: Optional[str] = None, + role_eligibility_schedule_id: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Returns role eligibility schedule instances of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility schedule instances of the specific role + definition. + :paramtype role_definition_id: str + :keyword status: Returns role eligibility schedule instances of the specific status. + :paramtype status: str + :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to + a specific role eligibility schedule. + :paramtype role_eligibility_schedule_id: str + """ + super(RoleEligibilityScheduleInstanceFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.status = status + self.role_eligibility_schedule_id = role_eligibility_schedule_id + + +class RoleEligibilityScheduleInstanceListResult(msrest.serialization.Model): + """Role eligibility schedule instance list operation result. + + :ivar value: Role eligibility schedule instance list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleEligibilityScheduleInstance]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleEligibilityScheduleInstance"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role eligibility schedule instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleEligibilityScheduleInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleListResult(msrest.serialization.Model): + """role eligibility schedule list operation result. + + :ivar value: role eligibility schedule list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleEligibilitySchedule]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleEligibilitySchedule"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: role eligibility schedule list. + :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleEligibilityScheduleListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleRequest(msrest.serialization.Model): + """Role Eligibility schedule request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role eligibility schedule request ID. + :vartype id: str + :ivar name: The role eligibility schedule request name. + :vartype name: str + :ivar type: The role eligibility schedule request type. + :vartype type: str + :ivar scope: The role eligibility schedule request scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01.models.PrincipalType + :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", + "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". + :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType + :ivar status: The status of the role eligibility schedule request. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01.models.Status + :ivar approval_id: The approvalId of the role eligibility schedule request. + :vartype approval_id: str + :ivar schedule_info: Schedule info of the role eligibility schedule. + :vartype schedule_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo + :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + role eligibility schedule id being updated. + :vartype target_role_eligibility_schedule_id: str + :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id + being updated. + :vartype target_role_eligibility_schedule_instance_id: str + :ivar justification: Justification for the role eligibility. + :vartype justification: str + :ivar ticket_info: Ticket Info of the role eligibility. + :vartype ticket_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesTicketInfo + :ivar condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule request was created. + :vartype created_on: ~datetime.datetime + :ivar requestor_id: Id of the user who created this request. + :vartype requestor_id: str + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01.models.ExpandedProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'scope': {'readonly': True}, + 'principal_type': {'readonly': True}, + 'status': {'readonly': True}, + 'approval_id': {'readonly': True}, + 'created_on': {'readonly': True}, + 'requestor_id': {'readonly': True}, + 'expanded_properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, + 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, + 'request_type': {'key': 'properties.requestType', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'approval_id': {'key': 'properties.approvalId', 'type': 'str'}, + 'schedule_info': {'key': 'properties.scheduleInfo', 'type': 'RoleEligibilityScheduleRequestPropertiesScheduleInfo'}, + 'target_role_eligibility_schedule_id': {'key': 'properties.targetRoleEligibilityScheduleId', 'type': 'str'}, + 'target_role_eligibility_schedule_instance_id': {'key': 'properties.targetRoleEligibilityScheduleInstanceId', 'type': 'str'}, + 'justification': {'key': 'properties.justification', 'type': 'str'}, + 'ticket_info': {'key': 'properties.ticketInfo', 'type': 'RoleEligibilityScheduleRequestPropertiesTicketInfo'}, + 'condition': {'key': 'properties.condition', 'type': 'str'}, + 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, + 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, + 'requestor_id': {'key': 'properties.requestorId', 'type': 'str'}, + 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, + } + + def __init__( + self, + *, + role_definition_id: Optional[str] = None, + principal_id: Optional[str] = None, + request_type: Optional[Union[str, "RequestType"]] = None, + schedule_info: Optional["RoleEligibilityScheduleRequestPropertiesScheduleInfo"] = None, + target_role_eligibility_schedule_id: Optional[str] = None, + target_role_eligibility_schedule_instance_id: Optional[str] = None, + justification: Optional[str] = None, + ticket_info: Optional["RoleEligibilityScheduleRequestPropertiesTicketInfo"] = None, + condition: Optional[str] = None, + condition_version: Optional[str] = None, + **kwargs + ): + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", + "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". + :paramtype request_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RequestType + :keyword schedule_info: Schedule info of the role eligibility schedule. + :paramtype schedule_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo + :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + role eligibility schedule id being updated. + :paramtype target_role_eligibility_schedule_id: str + :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance + id being updated. + :paramtype target_role_eligibility_schedule_instance_id: str + :keyword justification: Justification for the role eligibility. + :paramtype justification: str + :keyword ticket_info: Ticket Info of the role eligibility. + :paramtype ticket_info: + ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesTicketInfo + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + """ + super(RoleEligibilityScheduleRequest, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = None + self.role_definition_id = role_definition_id + self.principal_id = principal_id + self.principal_type = None + self.request_type = request_type + self.status = None + self.approval_id = None + self.schedule_info = schedule_info + self.target_role_eligibility_schedule_id = target_role_eligibility_schedule_id + self.target_role_eligibility_schedule_instance_id = target_role_eligibility_schedule_instance_id + self.justification = justification + self.ticket_info = ticket_info + self.condition = condition + self.condition_version = condition_version + self.created_on = None + self.requestor_id = None + self.expanded_properties = None + + +class RoleEligibilityScheduleRequestFilter(msrest.serialization.Model): + """Role eligibility schedule request filter. + + :ivar principal_id: Returns role eligibility requests of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility requests of the specific role definition. + :vartype role_definition_id: str + :ivar requestor_id: Returns role eligibility requests created by specific principal. + :vartype requestor_id: str + :ivar status: Returns role eligibility requests of specific status. + :vartype status: str + """ + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, + 'requestor_id': {'key': 'requestorId', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + role_definition_id: Optional[str] = None, + requestor_id: Optional[str] = None, + status: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: Returns role eligibility requests of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility requests of the specific role definition. + :paramtype role_definition_id: str + :keyword requestor_id: Returns role eligibility requests created by specific principal. + :paramtype requestor_id: str + :keyword status: Returns role eligibility requests of specific status. + :paramtype status: str + """ + super(RoleEligibilityScheduleRequestFilter, self).__init__(**kwargs) + self.principal_id = principal_id + self.role_definition_id = role_definition_id + self.requestor_id = requestor_id + self.status = status + + +class RoleEligibilityScheduleRequestListResult(msrest.serialization.Model): + """Role eligibility schedule request list operation result. + + :ivar value: Role eligibility schedule request list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleEligibilityScheduleRequest]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleEligibilityScheduleRequest"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role eligibility schedule request list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleEligibilityScheduleRequestListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleEligibilityScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): + """Schedule info of the role eligibility schedule. + + :ivar start_date_time: Start DateTime of the role eligibility schedule. + :vartype start_date_time: ~datetime.datetime + :ivar expiration: Expiration of the role eligibility schedule. + :vartype expiration: + ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + """ + + _attribute_map = { + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'expiration': {'key': 'expiration', 'type': 'RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration'}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + expiration: Optional["RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, + **kwargs + ): + """ + :keyword start_date_time: Start DateTime of the role eligibility schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword expiration: Expiration of the role eligibility schedule. + :paramtype expiration: + ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + """ + super(RoleEligibilityScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) + self.start_date_time = start_date_time + self.expiration = expiration + + +class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): + """Expiration of the role eligibility schedule. + + :ivar type: Type of the role eligibility schedule expiration. Possible values include: + "AfterDuration", "AfterDateTime", "NoExpiration". + :vartype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type + :ivar end_date_time: End DateTime of the role eligibility schedule. + :vartype end_date_time: ~datetime.datetime + :ivar duration: Duration of the role eligibility schedule in TimeSpan. + :vartype duration: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'end_date_time': {'key': 'endDateTime', 'type': 'iso-8601'}, + 'duration': {'key': 'duration', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "Type"]] = None, + end_date_time: Optional[datetime.datetime] = None, + duration: Optional[str] = None, + **kwargs + ): + """ + :keyword type: Type of the role eligibility schedule expiration. Possible values include: + "AfterDuration", "AfterDateTime", "NoExpiration". + :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01.models.Type + :keyword end_date_time: End DateTime of the role eligibility schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword duration: Duration of the role eligibility schedule in TimeSpan. + :paramtype duration: str + """ + super(RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) + self.type = type + self.end_date_time = end_date_time + self.duration = duration + + +class RoleEligibilityScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): + """Ticket Info of the role eligibility. + + :ivar ticket_number: Ticket number for the role eligibility. + :vartype ticket_number: str + :ivar ticket_system: Ticket system name for the role eligibility. + :vartype ticket_system: str + """ + + _attribute_map = { + 'ticket_number': {'key': 'ticketNumber', 'type': 'str'}, + 'ticket_system': {'key': 'ticketSystem', 'type': 'str'}, + } + + def __init__( + self, + *, + ticket_number: Optional[str] = None, + ticket_system: Optional[str] = None, + **kwargs + ): + """ + :keyword ticket_number: Ticket number for the role eligibility. + :paramtype ticket_number: str + :keyword ticket_system: Ticket system name for the role eligibility. + :paramtype ticket_system: str + """ + super(RoleEligibilityScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) + self.ticket_number = ticket_number + self.ticket_system = ticket_system + + +class RoleManagementPolicy(msrest.serialization.Model): + """Role management policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role management policy Id. + :vartype id: str + :ivar name: The role management policy name. + :vartype name: str + :ivar type: The role management policy type. + :vartype type: str + :ivar scope: The role management policy scope. + :vartype scope: str + :ivar display_name: The role management policy display name. + :vartype display_name: str + :ivar description: The role management policy description. + :vartype description: str + :ivar is_organization_default: The role management policy is default policy. + :vartype is_organization_default: bool + :ivar last_modified_by: The name of the entity last modified it. + :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01.models.Principal + :ivar last_modified_date_time: The last modified date time. + :vartype last_modified_date_time: ~datetime.datetime + :ivar rules: The rule applied to the policy. + :vartype rules: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] + :ivar effective_rules: The readonly computed rule applied to the policy. + :vartype effective_rules: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] + :ivar policy_properties: Additional properties of scope. + :vartype policy_properties: ~azure.mgmt.authorization.v2020_10_01.models.PolicyProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'last_modified_by': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'effective_rules': {'readonly': True}, + 'policy_properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'is_organization_default': {'key': 'properties.isOrganizationDefault', 'type': 'bool'}, + 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'Principal'}, + 'last_modified_date_time': {'key': 'properties.lastModifiedDateTime', 'type': 'iso-8601'}, + 'rules': {'key': 'properties.rules', 'type': '[RoleManagementPolicyRule]'}, + 'effective_rules': {'key': 'properties.effectiveRules', 'type': '[RoleManagementPolicyRule]'}, + 'policy_properties': {'key': 'properties.policyProperties', 'type': 'PolicyProperties'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + display_name: Optional[str] = None, + description: Optional[str] = None, + is_organization_default: Optional[bool] = None, + rules: Optional[List["RoleManagementPolicyRule"]] = None, + **kwargs + ): + """ + :keyword scope: The role management policy scope. + :paramtype scope: str + :keyword display_name: The role management policy display name. + :paramtype display_name: str + :keyword description: The role management policy description. + :paramtype description: str + :keyword is_organization_default: The role management policy is default policy. + :paramtype is_organization_default: bool + :keyword rules: The rule applied to the policy. + :paramtype rules: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] + """ + super(RoleManagementPolicy, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = scope + self.display_name = display_name + self.description = description + self.is_organization_default = is_organization_default + self.last_modified_by = None + self.last_modified_date_time = None + self.rules = rules + self.effective_rules = None + self.policy_properties = None + + +class RoleManagementPolicyRule(msrest.serialization.Model): + """The role management policy rule. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule". + :vartype rule_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + """ + + _validation = { + 'rule_type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'rule_type': {'key': 'ruleType', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, + } + + _subtype_map = { + 'rule_type': {'RoleManagementPolicyApprovalRule': 'RoleManagementPolicyApprovalRule', 'RoleManagementPolicyAuthenticationContextRule': 'RoleManagementPolicyAuthenticationContextRule', 'RoleManagementPolicyEnablementRule': 'RoleManagementPolicyEnablementRule', 'RoleManagementPolicyExpirationRule': 'RoleManagementPolicyExpirationRule', 'RoleManagementPolicyNotificationRule': 'RoleManagementPolicyNotificationRule'} + } + + def __init__( + self, + *, + id: Optional[str] = None, + target: Optional["RoleManagementPolicyRuleTarget"] = None, + **kwargs + ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + """ + super(RoleManagementPolicyRule, self).__init__(**kwargs) + self.id = id + self.rule_type = None # type: Optional[str] + self.target = target + + +class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): + """The role management policy approval rule. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule". + :vartype rule_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :ivar setting: The approval setting. + :vartype setting: ~azure.mgmt.authorization.v2020_10_01.models.ApprovalSettings + """ + + _validation = { + 'rule_type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'rule_type': {'key': 'ruleType', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, + 'setting': {'key': 'setting', 'type': 'ApprovalSettings'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + target: Optional["RoleManagementPolicyRuleTarget"] = None, + setting: Optional["ApprovalSettings"] = None, + **kwargs + ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :keyword setting: The approval setting. + :paramtype setting: ~azure.mgmt.authorization.v2020_10_01.models.ApprovalSettings + """ + super(RoleManagementPolicyApprovalRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyApprovalRule' # type: str + self.setting = setting + + +class RoleManagementPolicyAssignment(msrest.serialization.Model): + """Role management policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The role management policy Id. + :vartype id: str + :ivar name: The role management policy name. + :vartype name: str + :ivar type: The role management policy type. + :vartype type: str + :ivar scope: The role management policy scope. + :vartype scope: str + :ivar role_definition_id: The role definition of management policy assignment. + :vartype role_definition_id: str + :ivar policy_id: The policy id role management policy assignment. + :vartype policy_id: str + :ivar effective_rules: The readonly computed rule applied to the policy. + :vartype effective_rules: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRule] + :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. + :vartype policy_assignment_properties: + ~azure.mgmt.authorization.v2020_10_01.models.PolicyAssignmentProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'effective_rules': {'readonly': True}, + 'policy_assignment_properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'scope': {'key': 'properties.scope', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, + 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, + 'effective_rules': {'key': 'properties.effectiveRules', 'type': '[RoleManagementPolicyRule]'}, + 'policy_assignment_properties': {'key': 'properties.policyAssignmentProperties', 'type': 'PolicyAssignmentProperties'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + role_definition_id: Optional[str] = None, + policy_id: Optional[str] = None, + **kwargs + ): + """ + :keyword scope: The role management policy scope. + :paramtype scope: str + :keyword role_definition_id: The role definition of management policy assignment. + :paramtype role_definition_id: str + :keyword policy_id: The policy id role management policy assignment. + :paramtype policy_id: str + """ + super(RoleManagementPolicyAssignment, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.scope = scope + self.role_definition_id = role_definition_id + self.policy_id = policy_id + self.effective_rules = None + self.policy_assignment_properties = None + + +class RoleManagementPolicyAssignmentListResult(msrest.serialization.Model): + """Role management policy assignment list operation result. + + :ivar value: Role management policy assignment list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleManagementPolicyAssignment]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleManagementPolicyAssignment"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role management policy assignment list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleManagementPolicyAssignmentListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): + """The role management policy authentication context rule. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule". + :vartype rule_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :ivar is_enabled: The value indicating if rule is enabled. + :vartype is_enabled: bool + :ivar claim_value: The claim value. + :vartype claim_value: str + """ + + _validation = { + 'rule_type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'rule_type': {'key': 'ruleType', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, + 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, + 'claim_value': {'key': 'claimValue', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + target: Optional["RoleManagementPolicyRuleTarget"] = None, + is_enabled: Optional[bool] = None, + claim_value: Optional[str] = None, + **kwargs + ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :keyword is_enabled: The value indicating if rule is enabled. + :paramtype is_enabled: bool + :keyword claim_value: The claim value. + :paramtype claim_value: str + """ + super(RoleManagementPolicyAuthenticationContextRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyAuthenticationContextRule' # type: str + self.is_enabled = is_enabled + self.claim_value = claim_value + + +class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): + """The role management policy enablement rule. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule". + :vartype rule_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :ivar enabled_rules: The list of enabled rules. + :vartype enabled_rules: list[str or + ~azure.mgmt.authorization.v2020_10_01.models.EnablementRules] + """ + + _validation = { + 'rule_type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'rule_type': {'key': 'ruleType', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, + 'enabled_rules': {'key': 'enabledRules', 'type': '[str]'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + target: Optional["RoleManagementPolicyRuleTarget"] = None, + enabled_rules: Optional[List[Union[str, "EnablementRules"]]] = None, + **kwargs + ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :keyword enabled_rules: The list of enabled rules. + :paramtype enabled_rules: list[str or + ~azure.mgmt.authorization.v2020_10_01.models.EnablementRules] + """ + super(RoleManagementPolicyEnablementRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyEnablementRule' # type: str + self.enabled_rules = enabled_rules + + +class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): + """The role management policy expiration rule. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule". + :vartype rule_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :ivar is_expiration_required: The value indicating whether expiration is required. + :vartype is_expiration_required: bool + :ivar maximum_duration: The maximum duration of expiration in timespan. + :vartype maximum_duration: str + """ + + _validation = { + 'rule_type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'rule_type': {'key': 'ruleType', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, + 'is_expiration_required': {'key': 'isExpirationRequired', 'type': 'bool'}, + 'maximum_duration': {'key': 'maximumDuration', 'type': 'str'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + target: Optional["RoleManagementPolicyRuleTarget"] = None, + is_expiration_required: Optional[bool] = None, + maximum_duration: Optional[str] = None, + **kwargs + ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :keyword is_expiration_required: The value indicating whether expiration is required. + :paramtype is_expiration_required: bool + :keyword maximum_duration: The maximum duration of expiration in timespan. + :paramtype maximum_duration: str + """ + super(RoleManagementPolicyExpirationRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyExpirationRule' # type: str + self.is_expiration_required = is_expiration_required + self.maximum_duration = maximum_duration + + +class RoleManagementPolicyListResult(msrest.serialization.Model): + """Role management policy list operation result. + + :ivar value: Role management policy list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[RoleManagementPolicy]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["RoleManagementPolicy"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Role management policy list. + :paramtype value: list[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(RoleManagementPolicyListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): + """The role management policy notification rule. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", + "RoleManagementPolicyNotificationRule". + :vartype rule_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleType + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :ivar notification_type: The type of notification. Possible values include: "Email". + :vartype notification_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.NotificationDeliveryMechanism + :ivar notification_level: The notification level. Possible values include: "None", "Critical", + "All". + :vartype notification_level: str or + ~azure.mgmt.authorization.v2020_10_01.models.NotificationLevel + :ivar recipient_type: The recipient type. Possible values include: "Requestor", "Approver", + "Admin". + :vartype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RecipientType + :ivar notification_recipients: The list of notification recipients. + :vartype notification_recipients: list[str] + :ivar is_default_recipients_enabled: Determines if the notification will be sent to the + recipient type specified in the policy rule. + :vartype is_default_recipients_enabled: bool + """ + + _validation = { + 'rule_type': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'rule_type': {'key': 'ruleType', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, + 'notification_type': {'key': 'notificationType', 'type': 'str'}, + 'notification_level': {'key': 'notificationLevel', 'type': 'str'}, + 'recipient_type': {'key': 'recipientType', 'type': 'str'}, + 'notification_recipients': {'key': 'notificationRecipients', 'type': '[str]'}, + 'is_default_recipients_enabled': {'key': 'isDefaultRecipientsEnabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + target: Optional["RoleManagementPolicyRuleTarget"] = None, + notification_type: Optional[Union[str, "NotificationDeliveryMechanism"]] = None, + notification_level: Optional[Union[str, "NotificationLevel"]] = None, + recipient_type: Optional[Union[str, "RecipientType"]] = None, + notification_recipients: Optional[List[str]] = None, + is_default_recipients_enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyRuleTarget + :keyword notification_type: The type of notification. Possible values include: "Email". + :paramtype notification_type: str or + ~azure.mgmt.authorization.v2020_10_01.models.NotificationDeliveryMechanism + :keyword notification_level: The notification level. Possible values include: "None", + "Critical", "All". + :paramtype notification_level: str or + ~azure.mgmt.authorization.v2020_10_01.models.NotificationLevel + :keyword recipient_type: The recipient type. Possible values include: "Requestor", "Approver", + "Admin". + :paramtype recipient_type: str or ~azure.mgmt.authorization.v2020_10_01.models.RecipientType + :keyword notification_recipients: The list of notification recipients. + :paramtype notification_recipients: list[str] + :keyword is_default_recipients_enabled: Determines if the notification will be sent to the + recipient type specified in the policy rule. + :paramtype is_default_recipients_enabled: bool + """ + super(RoleManagementPolicyNotificationRule, self).__init__(id=id, target=target, **kwargs) + self.rule_type = 'RoleManagementPolicyNotificationRule' # type: str + self.notification_type = notification_type + self.notification_level = notification_level + self.recipient_type = recipient_type + self.notification_recipients = notification_recipients + self.is_default_recipients_enabled = is_default_recipients_enabled + + +class RoleManagementPolicyRuleTarget(msrest.serialization.Model): + """The role management policy rule target. + + :ivar caller: The caller of the setting. + :vartype caller: str + :ivar operations: The type of operation. + :vartype operations: list[str] + :ivar level: The assignment level to which rule is applied. + :vartype level: str + :ivar target_objects: The list of target objects. + :vartype target_objects: list[str] + :ivar inheritable_settings: The list of inheritable settings. + :vartype inheritable_settings: list[str] + :ivar enforced_settings: The list of enforced settings. + :vartype enforced_settings: list[str] + """ + + _attribute_map = { + 'caller': {'key': 'caller', 'type': 'str'}, + 'operations': {'key': 'operations', 'type': '[str]'}, + 'level': {'key': 'level', 'type': 'str'}, + 'target_objects': {'key': 'targetObjects', 'type': '[str]'}, + 'inheritable_settings': {'key': 'inheritableSettings', 'type': '[str]'}, + 'enforced_settings': {'key': 'enforcedSettings', 'type': '[str]'}, + } + + def __init__( + self, + *, + caller: Optional[str] = None, + operations: Optional[List[str]] = None, + level: Optional[str] = None, + target_objects: Optional[List[str]] = None, + inheritable_settings: Optional[List[str]] = None, + enforced_settings: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword caller: The caller of the setting. + :paramtype caller: str + :keyword operations: The type of operation. + :paramtype operations: list[str] + :keyword level: The assignment level to which rule is applied. + :paramtype level: str + :keyword target_objects: The list of target objects. + :paramtype target_objects: list[str] + :keyword inheritable_settings: The list of inheritable settings. + :paramtype inheritable_settings: list[str] + :keyword enforced_settings: The list of enforced settings. + :paramtype enforced_settings: list[str] + """ + super(RoleManagementPolicyRuleTarget, self).__init__(**kwargs) + self.caller = caller + self.operations = operations + self.level = level + self.target_objects = target_objects + self.inheritable_settings = inheritable_settings + self.enforced_settings = enforced_settings + + +class UserSet(msrest.serialization.Model): + """The detail of a user. + + :ivar user_type: The type of user. Possible values include: "User", "Group". + :vartype user_type: str or ~azure.mgmt.authorization.v2020_10_01.models.UserType + :ivar is_backup: The value indicating whether the user is a backup fallback approver. + :vartype is_backup: bool + :ivar id: The object id of the user. + :vartype id: str + :ivar description: The description of the user. + :vartype description: str + """ + + _attribute_map = { + 'user_type': {'key': 'userType', 'type': 'str'}, + 'is_backup': {'key': 'isBackup', 'type': 'bool'}, + 'id': {'key': 'id', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + user_type: Optional[Union[str, "UserType"]] = None, + is_backup: Optional[bool] = None, + id: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword user_type: The type of user. Possible values include: "User", "Group". + :paramtype user_type: str or ~azure.mgmt.authorization.v2020_10_01.models.UserType + :keyword is_backup: The value indicating whether the user is a backup fallback approver. + :paramtype is_backup: bool + :keyword id: The object id of the user. + :paramtype id: str + :keyword description: The description of the user. + :paramtype description: str + """ + super(UserSet, self).__init__(**kwargs) + self.user_type = user_type + self.is_backup = is_backup + self.id = id + self.description = description diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py new file mode 100644 index 000000000000..2c6abd246591 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._eligible_child_resources_operations import EligibleChildResourcesOperations +from ._role_assignment_schedules_operations import RoleAssignmentSchedulesOperations +from ._role_assignment_schedule_instances_operations import RoleAssignmentScheduleInstancesOperations +from ._role_assignment_schedule_requests_operations import RoleAssignmentScheduleRequestsOperations +from ._role_eligibility_schedules_operations import RoleEligibilitySchedulesOperations +from ._role_eligibility_schedule_instances_operations import RoleEligibilityScheduleInstancesOperations +from ._role_eligibility_schedule_requests_operations import RoleEligibilityScheduleRequestsOperations +from ._role_management_policies_operations import RoleManagementPoliciesOperations +from ._role_management_policy_assignments_operations import RoleManagementPolicyAssignmentsOperations + +__all__ = [ + 'EligibleChildResourcesOperations', + 'RoleAssignmentSchedulesOperations', + 'RoleAssignmentScheduleInstancesOperations', + 'RoleAssignmentScheduleRequestsOperations', + 'RoleEligibilitySchedulesOperations', + 'RoleEligibilityScheduleInstancesOperations', + 'RoleEligibilityScheduleRequestsOperations', + 'RoleManagementPoliciesOperations', + 'RoleManagementPolicyAssignmentsOperations', +] diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py new file mode 100644 index 000000000000..10451969ca95 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_eligible_child_resources_operations.py @@ -0,0 +1,168 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/eligibleChildResources") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class EligibleChildResourcesOperations(object): + """EligibleChildResourcesOperations 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.authorization.v2020_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 + + @distributed_trace + def get( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.EligibleChildResourcesListResult"]: + """Get the child resources of a resource on which user has eligible access. + + :param scope: The scope of the role management policy. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' + to filter on only resource of type = 'Subscription'. Use + $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource + of type = 'Subscription' or 'ResourceGroup'. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.EligibleChildResourcesListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.EligibleChildResourcesListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py new file mode 100644 index 000000000000..24ee0f25cfd2 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_instances_operations.py @@ -0,0 +1,262 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_schedule_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleInstanceName": _SERIALIZER.url("role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class RoleAssignmentScheduleInstancesOperations(object): + """RoleAssignmentScheduleInstancesOperations 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.authorization.v2020_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 + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentScheduleInstanceListResult"]: + """Gets role assignment schedule instances of a role assignment schedule. + + :param scope: The scope of the role assignment schedule. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role + assignment schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. + Use $filter=asTarget() to return all role assignment schedule instances created for the current + user. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} # type: ignore + + @distributed_trace + def get( + self, + scope: str, + role_assignment_schedule_instance_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleInstance": + """Gets the specified role assignment schedule instance. + + :param scope: The scope of the role assignments schedules. + :type scope: str + :param role_assignment_schedule_instance_name: The name (hash of schedule name + time) of the + role assignment schedule to get. + :type role_assignment_schedule_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py new file mode 100644 index 000000000000..d6f76a24983a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedule_requests_operations.py @@ -0,0 +1,571 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + scope: str, + role_assignment_schedule_request_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_cancel_request( + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_validate_request( + scope: str, + role_assignment_schedule_request_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class RoleAssignmentScheduleRequestsOperations(object): + """RoleAssignmentScheduleRequestsOperations 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.authorization.v2020_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 + + @distributed_trace + def create( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: "_models.RoleAssignmentScheduleRequest", + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": + """Creates a role assignment schedule request. + + :param scope: The scope of the role assignment schedule request to create. The scope can be any + REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a + subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a + resource group, and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' + for a resource. + :type scope: str + :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The + name must be unique and different for each role assignment. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_create_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace + def get( + self, + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": + """Get the specified role assignment schedule request. + + :param scope: The scope of the role assignment schedule request. + :type scope: str + :param role_assignment_schedule_request_name: The name (guid) of the role assignment schedule + request to get. + :type role_assignment_schedule_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentScheduleRequestListResult"]: + """Gets role assignment schedule requests for a scope. + + :param scope: The scope of the role assignments schedule requests. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return + all role assignment schedule requests at, above or below the scope for the specified principal. + Use $filter=asRequestor() to return all role assignment schedule requests requested by the + current user. Use $filter=asTarget() to return all role assignment schedule requests created + for the current user. Use $filter=asApprover() to return all role assignment schedule requests + where the current user is an approver. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequestListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} # type: ignore + + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any + ) -> None: + """Cancels a pending role assignment schedule request. + + :param scope: The scope of the role assignment request to cancel. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + cancel. + :type role_assignment_schedule_request_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_cancel_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel"} # type: ignore + + + @distributed_trace + def validate( + self, + scope: str, + role_assignment_schedule_request_name: str, + parameters: "_models.RoleAssignmentScheduleRequest", + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": + """Validates a new role assignment schedule request. + + :param scope: The scope of the role assignment request to validate. + :type scope: str + :param role_assignment_schedule_request_name: The name of the role assignment request to + validate. + :type role_assignment_schedule_request_name: str + :param parameters: Parameters for the role assignment schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_validate_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/validate"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py new file mode 100644 index 000000000000..3bc35bd46070 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_assignment_schedules_operations.py @@ -0,0 +1,261 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_assignment_schedule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleName": _SERIALIZER.url("role_assignment_schedule_name", role_assignment_schedule_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class RoleAssignmentSchedulesOperations(object): + """RoleAssignmentSchedulesOperations 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.authorization.v2020_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 + + @distributed_trace + def get( + self, + scope: str, + role_assignment_schedule_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentSchedule": + """Get the specified role assignment schedule for a resource scope. + + :param scope: The scope of the role assignment schedule. + :type scope: str + :param role_assignment_schedule_name: The name (guid) of the role assignment schedule to get. + :type role_assignment_schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleAssignmentSchedule, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentSchedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentSchedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_assignment_schedule_name=role_assignment_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleAssignmentSchedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentScheduleListResult"]: + """Gets role assignment schedules for a resource scope. + + :param scope: The scope of the role assignments schedules. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role + assignment schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. + Use $filter=asTarget() to return all role assignment schedules created for the current user. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleAssignmentScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py new file mode 100644 index 000000000000..07673f2866f8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_instances_operations.py @@ -0,0 +1,262 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_eligibility_schedule_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleInstanceName": _SERIALIZER.url("role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class RoleEligibilityScheduleInstancesOperations(object): + """RoleEligibilityScheduleInstancesOperations 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.authorization.v2020_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 + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleEligibilityScheduleInstanceListResult"]: + """Gets role eligibility schedule instances of a role eligibility schedule. + + :param scope: The scope of the role eligibility schedule. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role + assignment schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use + $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} # type: ignore + + @distributed_trace + def get( + self, + scope: str, + role_eligibility_schedule_instance_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleInstance": + """Gets the specified role eligibility schedule instance. + + :param scope: The scope of the role eligibility schedules. + :type scope: str + :param role_eligibility_schedule_instance_name: The name (hash of schedule name + time) of the + role eligibility schedule to get. + :type role_eligibility_schedule_instance_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py new file mode 100644 index 000000000000..b44041baeca6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedule_requests_operations.py @@ -0,0 +1,571 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + scope: str, + role_eligibility_schedule_request_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_cancel_request( + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_validate_request( + scope: str, + role_eligibility_schedule_request_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class RoleEligibilityScheduleRequestsOperations(object): + """RoleEligibilityScheduleRequestsOperations 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.authorization.v2020_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 + + @distributed_trace + def create( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: "_models.RoleEligibilityScheduleRequest", + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": + """Creates a role eligibility schedule request. + + :param scope: The scope of the role eligibility schedule request to create. The scope can be + any REST resource instance. For example, use '/subscriptions/{subscription-id}/' for a + subscription, '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}' for a + resource group, and + '/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' + for a resource. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility to create. It + can be any valid GUID. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_create_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace + def get( + self, + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": + """Get the specified role eligibility schedule request. + + :param scope: The scope of the role eligibility schedule request. + :type scope: str + :param role_eligibility_schedule_request_name: The name (guid) of the role eligibility schedule + request to get. + :type role_eligibility_schedule_request_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleEligibilityScheduleRequestListResult"]: + """Gets role eligibility schedule requests for a scope. + + :param scope: The scope of the role eligibility schedule requests. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return + all role eligibility schedule requests at, above or below the scope for the specified + principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested + by the current user. Use $filter=asTarget() to return all role eligibility schedule requests + created for the current user. Use $filter=asApprover() to return all role eligibility schedule + requests where the current user is an approver. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequestListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequestListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} # type: ignore + + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any + ) -> None: + """Cancels a pending role eligibility schedule request. + + :param scope: The scope of the role eligibility request to cancel. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + cancel. + :type role_eligibility_schedule_request_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_cancel_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel"} # type: ignore + + + @distributed_trace + def validate( + self, + scope: str, + role_eligibility_schedule_request_name: str, + parameters: "_models.RoleEligibilityScheduleRequest", + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": + """Validates a new role eligibility schedule request. + + :param scope: The scope of the role eligibility request to validate. + :type scope: str + :param role_eligibility_schedule_request_name: The name of the role eligibility request to + validate. + :type role_eligibility_schedule_request_name: str + :param parameters: Parameters for the role eligibility schedule request. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilityScheduleRequest, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleRequest + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequest"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_validate_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilityScheduleRequest', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/validate"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py new file mode 100644 index 000000000000..aa11b1b43e41 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_eligibility_schedules_operations.py @@ -0,0 +1,261 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_eligibility_schedule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleName": _SERIALIZER.url("role_eligibility_schedule_name", role_eligibility_schedule_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class RoleEligibilitySchedulesOperations(object): + """RoleEligibilitySchedulesOperations 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.authorization.v2020_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 + + @distributed_trace + def get( + self, + scope: str, + role_eligibility_schedule_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilitySchedule": + """Get the specified role eligibility schedule for a resource scope. + + :param scope: The scope of the role eligibility schedule. + :type scope: str + :param role_eligibility_schedule_name: The name (guid) of the role eligibility schedule to get. + :type role_eligibility_schedule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleEligibilitySchedule, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilitySchedule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilitySchedule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_eligibility_schedule_name=role_eligibility_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleEligibilitySchedule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleEligibilityScheduleListResult"]: + """Gets role eligibility schedules for a resource scope. + + :param scope: The scope of the role eligibility schedules. + :type scope: str + :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role + eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role + eligibility schedules at, above or below the scope for the specified principal. Use + $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use + $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleEligibilityScheduleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py new file mode 100644 index 000000000000..124e9cfbe0db --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policies_operations.py @@ -0,0 +1,441 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_management_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + scope: str, + role_management_policy_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_management_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class RoleManagementPoliciesOperations(object): + """RoleManagementPoliciesOperations 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.authorization.v2020_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 + + @distributed_trace + def get( + self, + scope: str, + role_management_policy_name: str, + **kwargs: Any + ) -> "_models.RoleManagementPolicy": + """Get the specified role management policy for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to get. + :type role_management_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace + def update( + self, + scope: str, + role_management_policy_name: str, + parameters: "_models.RoleManagementPolicy", + **kwargs: Any + ) -> "_models.RoleManagementPolicy": + """Update a role management policy. + + :param scope: The scope of the role management policy to upsert. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :type role_management_policy_name: str + :param parameters: Parameters for the role management policy. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicy, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicy + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicy"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicy') + + request = build_update_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicy', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_management_policy_name: str, + **kwargs: Any + ) -> None: + """Delete a role management policy. + + :param scope: The scope of the role management policy to upsert. + :type scope: str + :param role_management_policy_name: The name (guid) of the role management policy to upsert. + :type role_management_policy_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_delete_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> Iterable["_models.RoleManagementPolicyListResult"]: + """Gets role management policies for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py new file mode 100644 index 000000000000..b1fda3db0eac --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/operations/_role_management_policy_assignments_operations.py @@ -0,0 +1,444 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyAssignmentName": _SERIALIZER.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_management_policy_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyAssignmentName": _SERIALIZER.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyAssignmentName": _SERIALIZER.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class RoleManagementPolicyAssignmentsOperations(object): + """RoleManagementPolicyAssignmentsOperations 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.authorization.v2020_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 + + @distributed_trace + def get( + self, + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any + ) -> "_models.RoleManagementPolicyAssignment": + """Get the specified role management policy assignment for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to get. + :type role_management_policy_assignment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_get_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace + def create( + self, + scope: str, + role_management_policy_assignment_name: str, + parameters: "_models.RoleManagementPolicyAssignment", + **kwargs: Any + ) -> "_models.RoleManagementPolicyAssignment": + """Create a role management policy assignment. + + :param scope: The scope of the role management policy assignment to upsert. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to upsert. + :type role_management_policy_assignment_name: str + :param parameters: Parameters for the role management policy assignment. + :type parameters: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :keyword callable cls: A custom type or function that will be passed the direct response + :return: RoleManagementPolicyAssignment, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignment + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignment"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') + + request = build_create_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('RoleManagementPolicyAssignment', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any + ) -> None: + """Delete a role management policy assignment. + + :param scope: The scope of the role management policy assignment to delete. + :type scope: str + :param role_management_policy_assignment_name: The name of format {guid_guid} the role + management policy assignment to delete. + :type role_management_policy_assignment_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 = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + + request = build_delete_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace + def list_for_scope( + self, + scope: str, + **kwargs: Any + ) -> Iterable["_models.RoleManagementPolicyAssignmentListResult"]: + """Gets role management assignment policies for a resource scope. + + :param scope: The scope of the role management policy. + :type scope: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01.models.RoleManagementPolicyAssignmentListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2020-10-01") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignmentListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py index ea267e40412d..b972b051c77f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_authorization_management_client.py @@ -6,118 +6,120 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations -from .operations import EligibleChildResourcesOperations -from .operations import RoleAssignmentSchedulesOperations -from .operations import RoleAssignmentScheduleInstancesOperations -from .operations import RoleAssignmentScheduleRequestsOperations -from .operations import RoleEligibilitySchedulesOperations -from .operations import RoleEligibilityScheduleInstancesOperations -from .operations import RoleEligibilityScheduleRequestsOperations -from .operations import RoleManagementPoliciesOperations -from .operations import RoleManagementPolicyAssignmentsOperations from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleAssignmentsOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentsOperations :ivar eligible_child_resources: EligibleChildResourcesOperations operations - :vartype eligible_child_resources: azure.mgmt.authorization.v2020_10_01_preview.operations.EligibleChildResourcesOperations + :vartype eligible_child_resources: + azure.mgmt.authorization.v2020_10_01_preview.operations.EligibleChildResourcesOperations :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations - :vartype role_assignment_schedules: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentSchedulesOperations + :vartype role_assignment_schedules: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentSchedulesOperations :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations - :vartype role_assignment_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleInstancesOperations + :vartype role_assignment_schedule_instances: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleInstancesOperations :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleRequestsOperations + :vartype role_assignment_schedule_requests: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleAssignmentScheduleRequestsOperations :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations - :vartype role_eligibility_schedules: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilitySchedulesOperations - :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations operations - :vartype role_eligibility_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleInstancesOperations + :vartype role_eligibility_schedules: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilitySchedulesOperations + :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations + operations + :vartype role_eligibility_schedule_instances: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleInstancesOperations :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleRequestsOperations + :vartype role_eligibility_schedule_requests: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleEligibilityScheduleRequestsOperations :ivar role_management_policies: RoleManagementPoliciesOperations operations - :vartype role_management_policies: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPoliciesOperations + :vartype role_management_policies: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPoliciesOperations :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations - :vartype role_management_policy_assignments: azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPolicyAssignmentsOperations + :vartype role_management_policy_assignments: + azure.mgmt.authorization.v2020_10_01_preview.operations.RoleManagementPolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.eligible_child_resources = EligibleChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policies = RoleManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py index 9e18c0b43993..835ade9777b0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-10-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json index bd67cca3e126..3455dc399fbc 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "role_assignments": "RoleAssignmentsOperations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py index a1de37eddf53..24f9eada1d54 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_authorization_management_client.py @@ -6,114 +6,120 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import RoleAssignmentsOperations -from .operations import EligibleChildResourcesOperations -from .operations import RoleAssignmentSchedulesOperations -from .operations import RoleAssignmentScheduleInstancesOperations -from .operations import RoleAssignmentScheduleRequestsOperations -from .operations import RoleEligibilitySchedulesOperations -from .operations import RoleEligibilityScheduleInstancesOperations -from .operations import RoleEligibilityScheduleRequestsOperations -from .operations import RoleManagementPoliciesOperations -from .operations import RoleManagementPolicyAssignmentsOperations from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import EligibleChildResourcesOperations, RoleAssignmentScheduleInstancesOperations, RoleAssignmentScheduleRequestsOperations, RoleAssignmentSchedulesOperations, RoleAssignmentsOperations, RoleEligibilityScheduleInstancesOperations, RoleEligibilityScheduleRequestsOperations, RoleEligibilitySchedulesOperations, RoleManagementPoliciesOperations, RoleManagementPolicyAssignmentsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Role based access control provides you a way to apply granular level policy administration down to individual resources or resource groups. These operations enable you to manage role assignments. A role assignment grants access to Azure Active Directory users. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Role based access control provides you a way to apply granular level policy administration down + to individual resources or resource groups. These operations enable you to manage role + assignments. A role assignment grants access to Azure Active Directory users. :ivar role_assignments: RoleAssignmentsOperations operations - :vartype role_assignments: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations + :vartype role_assignments: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentsOperations :ivar eligible_child_resources: EligibleChildResourcesOperations operations - :vartype eligible_child_resources: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations + :vartype eligible_child_resources: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.EligibleChildResourcesOperations :ivar role_assignment_schedules: RoleAssignmentSchedulesOperations operations - :vartype role_assignment_schedules: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations + :vartype role_assignment_schedules: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentSchedulesOperations :ivar role_assignment_schedule_instances: RoleAssignmentScheduleInstancesOperations operations - :vartype role_assignment_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations + :vartype role_assignment_schedule_instances: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleInstancesOperations :ivar role_assignment_schedule_requests: RoleAssignmentScheduleRequestsOperations operations - :vartype role_assignment_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations + :vartype role_assignment_schedule_requests: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleAssignmentScheduleRequestsOperations :ivar role_eligibility_schedules: RoleEligibilitySchedulesOperations operations - :vartype role_eligibility_schedules: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations - :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations operations - :vartype role_eligibility_schedule_instances: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations + :vartype role_eligibility_schedules: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilitySchedulesOperations + :ivar role_eligibility_schedule_instances: RoleEligibilityScheduleInstancesOperations + operations + :vartype role_eligibility_schedule_instances: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleInstancesOperations :ivar role_eligibility_schedule_requests: RoleEligibilityScheduleRequestsOperations operations - :vartype role_eligibility_schedule_requests: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations + :vartype role_eligibility_schedule_requests: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleEligibilityScheduleRequestsOperations :ivar role_management_policies: RoleManagementPoliciesOperations operations - :vartype role_management_policies: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations + :vartype role_management_policies: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPoliciesOperations :ivar role_management_policy_assignments: RoleManagementPolicyAssignmentsOperations operations - :vartype role_management_policy_assignments: azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations + :vartype role_management_policy_assignments: + azure.mgmt.authorization.v2020_10_01_preview.aio.operations.RoleManagementPolicyAssignmentsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.role_assignments = RoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.eligible_child_resources = EligibleChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedules = RoleAssignmentSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedules = RoleEligibilitySchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policies = RoleManagementPoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.role_assignments = RoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.eligible_child_resources = EligibleChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedules = RoleAssignmentSchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_instances = RoleAssignmentScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_schedule_requests = RoleAssignmentScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedules = RoleEligibilitySchedulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_instances = RoleEligibilityScheduleInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_eligibility_schedule_requests = RoleEligibilityScheduleRequestsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policies = RoleManagementPoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_management_policy_assignments = RoleManagementPolicyAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py index 9977bad5f6d4..cc3cf3432cf3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2020-10-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-10-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py index 61bbae50ecc7..72e38615f9e2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_eligible_child_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._eligible_child_resources_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def get( self, scope: str, @@ -54,48 +58,49 @@ def get( :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource - of type = 'Subscription' or 'ResourceGroup'. + of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EligibleChildResourcesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] + :return: An iterator like instance of either EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.EligibleChildResourcesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EligibleChildResourcesListResult', pipeline_response) + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,7 +109,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -113,7 +122,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/eligibleChildResources'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py index 3efcc5ed2bdf..1953ec9b836e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_schedule_instances_operations import build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_scope( self, scope: str, @@ -56,48 +61,49 @@ def list_for_scope( assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current - user. + user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] + :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,11 +125,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} # type: ignore + @distributed_trace_async async def get( self, scope: str, @@ -143,27 +155,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleInstanceName': self._serialize.url("role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -176,4 +185,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py index d5c1a38e36bd..9ad3750181d2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedule_requests_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_schedule_requests_operations import build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, scope: str, @@ -58,11 +63,12 @@ async def create( '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment to create. It can - be any valid GUID. + :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The + name must be unique and different for each role assignment. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest @@ -73,32 +79,28 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_create_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -111,8 +113,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -136,27 +141,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,8 +171,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, @@ -187,48 +192,49 @@ def list_for_scope( Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests - where the current user is an approver. + where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] + :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequestListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -237,7 +243,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,12 +256,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} # type: ignore - async def cancel( + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_assignment_schedule_request_name: str, @@ -274,27 +286,24 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,4 +313,5 @@ async def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py index 0a60be766dc9..02e14300d3e5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignment_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_schedules_operations import build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -63,27 +68,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleName': self._serialize.url("role_assignment_schedule_name", role_assignment_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_schedule_name=role_assignment_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, @@ -113,47 +118,49 @@ def list_for_scope( assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] + :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,7 +169,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,7 +182,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py index 9e0bb270be85..529244aebc06 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignments_operations import build_create_by_id_request, build_create_request, build_delete_by_id_request, build_delete_request, build_get_by_id_request, build_get_request, build_list_for_resource_group_request, build_list_for_resource_request, build_list_for_scope_request, build_list_for_subscription_request, build_validate_by_id_request, build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_subscription( self, filter: Optional[str] = None, @@ -51,52 +56,53 @@ def list_for_subscription( :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +111,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, resource_group_name: str, @@ -133,53 +145,55 @@ def list_for_resource_group( :type resource_group_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -188,21 +202,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource( self, resource_group_name: str, @@ -226,56 +246,61 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -284,21 +309,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def get( self, scope: str, @@ -315,7 +346,7 @@ async def get( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -327,34 +358,30 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(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 tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -363,8 +390,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, @@ -382,7 +412,8 @@ async def create( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment @@ -393,37 +424,33 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -436,8 +463,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def delete( self, scope: str, @@ -454,7 +484,7 @@ async def delete( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -466,34 +496,30 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(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 tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -504,8 +530,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace_async async def validate( self, scope: str, @@ -523,7 +552,8 @@ async def validate( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse @@ -534,37 +564,33 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -573,8 +599,11 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate'} # type: ignore + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, @@ -591,52 +620,53 @@ def list_for_scope( :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -645,21 +675,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace_async async def get_by_id( self, role_assignment_id: str, @@ -673,7 +709,7 @@ async def get_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -685,33 +721,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -720,8 +752,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def create_by_id( self, role_assignment_id: str, @@ -736,7 +771,8 @@ async def create_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment @@ -747,36 +783,32 @@ async def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -789,8 +821,11 @@ async def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def delete_by_id( self, role_assignment_id: str, @@ -804,7 +839,7 @@ async def delete_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -816,33 +851,29 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -853,8 +884,11 @@ async def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace_async async def validate_by_id( self, role_assignment_id: str, @@ -869,7 +903,8 @@ async def validate_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse @@ -880,36 +915,32 @@ async def validate_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -918,4 +949,6 @@ async def validate_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - validate_by_id.metadata = {'url': '/{roleAssignmentId}/validate'} # type: ignore + + validate_by_id.metadata = {'url': "/{roleAssignmentId}/validate"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py index 87f2bc311b3e..3b1aa2cac0b8 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_eligibility_schedule_instances_operations import build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_for_scope( self, scope: str, @@ -56,47 +61,49 @@ def list_for_scope( assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] + :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,7 +112,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -114,11 +125,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} # type: ignore + @distributed_trace_async async def get( self, scope: str, @@ -142,27 +155,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleInstanceName': self._serialize.url("role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,4 +185,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py index fced3034ad24..ac6e441cc96d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedule_requests_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_eligibility_schedule_requests_operations import build_cancel_request, build_create_request, build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create( self, scope: str, @@ -62,7 +67,8 @@ async def create( can be any valid GUID. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest @@ -73,32 +79,28 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_create_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -111,8 +113,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace_async async def get( self, scope: str, @@ -136,27 +141,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -169,8 +171,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, @@ -187,48 +192,49 @@ def list_for_scope( principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule - requests where the current user is an approver. + requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] + :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequestListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -237,7 +243,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -246,12 +256,14 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} # type: ignore - async def cancel( + @distributed_trace_async + async def cancel( # pylint: disable=inconsistent-return-statements self, scope: str, role_eligibility_schedule_request_name: str, @@ -274,27 +286,24 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -304,4 +313,5 @@ async def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py index d97827812dde..8727f3f6b467 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_eligibility_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_eligibility_schedules_operations import build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -63,27 +68,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleName': self._serialize.url("role_eligibility_schedule_name", role_eligibility_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_name=role_eligibility_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, scope: str, @@ -113,47 +118,49 @@ def list_for_scope( eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] + :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,7 +169,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -171,7 +182,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py index be9e97db7259..b3f78ad6f99c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_management_policies_operations import build_delete_request, build_get_request, build_list_for_scope_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -63,27 +68,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace_async async def update( self, scope: str, @@ -123,32 +128,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicy') + + request = build_update_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -161,9 +162,12 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore - async def delete( + update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_name: str, @@ -185,27 +189,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -215,8 +216,10 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, @@ -227,43 +230,44 @@ def list_for_scope( :param scope: The scope of the role management policy. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicyListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] + :return: An iterator like instance of either RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -272,7 +276,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,7 +289,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py index c43bf1591ab9..08ad4a6fd8e1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/aio/operations/_role_management_policy_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_management_policy_assignments_operations import build_create_request, build_delete_request, build_get_request, build_list_for_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, scope: str, @@ -64,27 +69,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_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') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -97,8 +99,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace_async async def create( self, scope: str, @@ -114,7 +119,8 @@ async def create( management policy assignment to upsert. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment @@ -125,32 +131,28 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') + + request = build_create_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -163,9 +165,12 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore - async def delete( + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, scope: str, role_management_policy_assignment_name: str, @@ -188,27 +193,24 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_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') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -218,8 +220,10 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + @distributed_trace def list_for_scope( self, scope: str, @@ -230,43 +234,44 @@ def list_for_scope( :param scope: The scope of the role management policy. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] + :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -275,7 +280,11 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,7 +293,8 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py index 7455c3e0a86b..9d53c9c66fc3 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/__init__.py @@ -6,132 +6,69 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApprovalSettings - from ._models_py3 import ApprovalStage - from ._models_py3 import CloudErrorBody - from ._models_py3 import EligibleChildResource - from ._models_py3 import EligibleChildResourcesListResult - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import ExpandedProperties - from ._models_py3 import ExpandedPropertiesPrincipal - from ._models_py3 import ExpandedPropertiesRoleDefinition - from ._models_py3 import ExpandedPropertiesScope - from ._models_py3 import Permission - from ._models_py3 import PolicyAssignmentProperties - from ._models_py3 import PolicyAssignmentPropertiesPolicy - from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition - from ._models_py3 import PolicyAssignmentPropertiesScope - from ._models_py3 import PolicyProperties - from ._models_py3 import PolicyPropertiesScope - from ._models_py3 import Principal - from ._models_py3 import RoleAssignment - from ._models_py3 import RoleAssignmentCreateParameters - from ._models_py3 import RoleAssignmentFilter - from ._models_py3 import RoleAssignmentListResult - from ._models_py3 import RoleAssignmentSchedule - from ._models_py3 import RoleAssignmentScheduleFilter - from ._models_py3 import RoleAssignmentScheduleInstance - from ._models_py3 import RoleAssignmentScheduleInstanceFilter - from ._models_py3 import RoleAssignmentScheduleInstanceListResult - from ._models_py3 import RoleAssignmentScheduleListResult - from ._models_py3 import RoleAssignmentScheduleRequest - from ._models_py3 import RoleAssignmentScheduleRequestFilter - from ._models_py3 import RoleAssignmentScheduleRequestListResult - from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo - from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo - from ._models_py3 import RoleEligibilitySchedule - from ._models_py3 import RoleEligibilityScheduleFilter - from ._models_py3 import RoleEligibilityScheduleInstance - from ._models_py3 import RoleEligibilityScheduleInstanceFilter - from ._models_py3 import RoleEligibilityScheduleInstanceListResult - from ._models_py3 import RoleEligibilityScheduleListResult - from ._models_py3 import RoleEligibilityScheduleRequest - from ._models_py3 import RoleEligibilityScheduleRequestFilter - from ._models_py3 import RoleEligibilityScheduleRequestListResult - from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo - from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo - from ._models_py3 import RoleManagementPolicy - from ._models_py3 import RoleManagementPolicyApprovalRule - from ._models_py3 import RoleManagementPolicyAssignment - from ._models_py3 import RoleManagementPolicyAssignmentListResult - from ._models_py3 import RoleManagementPolicyAuthenticationContextRule - from ._models_py3 import RoleManagementPolicyEnablementRule - from ._models_py3 import RoleManagementPolicyExpirationRule - from ._models_py3 import RoleManagementPolicyListResult - from ._models_py3 import RoleManagementPolicyNotificationRule - from ._models_py3 import RoleManagementPolicyRule - from ._models_py3 import RoleManagementPolicyRuleTarget - from ._models_py3 import UserSet - from ._models_py3 import ValidationResponse - from ._models_py3 import ValidationResponseErrorInfo -except (SyntaxError, ImportError): - from ._models import ApprovalSettings # type: ignore - from ._models import ApprovalStage # type: ignore - from ._models import CloudErrorBody # type: ignore - from ._models import EligibleChildResource # type: ignore - from ._models import EligibleChildResourcesListResult # type: ignore - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ExpandedProperties # type: ignore - from ._models import ExpandedPropertiesPrincipal # type: ignore - from ._models import ExpandedPropertiesRoleDefinition # type: ignore - from ._models import ExpandedPropertiesScope # type: ignore - from ._models import Permission # type: ignore - from ._models import PolicyAssignmentProperties # type: ignore - from ._models import PolicyAssignmentPropertiesPolicy # type: ignore - from ._models import PolicyAssignmentPropertiesRoleDefinition # type: ignore - from ._models import PolicyAssignmentPropertiesScope # type: ignore - from ._models import PolicyProperties # type: ignore - from ._models import PolicyPropertiesScope # type: ignore - from ._models import Principal # type: ignore - from ._models import RoleAssignment # type: ignore - from ._models import RoleAssignmentCreateParameters # type: ignore - from ._models import RoleAssignmentFilter # type: ignore - from ._models import RoleAssignmentListResult # type: ignore - from ._models import RoleAssignmentSchedule # type: ignore - from ._models import RoleAssignmentScheduleFilter # type: ignore - from ._models import RoleAssignmentScheduleInstance # type: ignore - from ._models import RoleAssignmentScheduleInstanceFilter # type: ignore - from ._models import RoleAssignmentScheduleInstanceListResult # type: ignore - from ._models import RoleAssignmentScheduleListResult # type: ignore - from ._models import RoleAssignmentScheduleRequest # type: ignore - from ._models import RoleAssignmentScheduleRequestFilter # type: ignore - from ._models import RoleAssignmentScheduleRequestListResult # type: ignore - from ._models import RoleAssignmentScheduleRequestPropertiesScheduleInfo # type: ignore - from ._models import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration # type: ignore - from ._models import RoleAssignmentScheduleRequestPropertiesTicketInfo # type: ignore - from ._models import RoleEligibilitySchedule # type: ignore - from ._models import RoleEligibilityScheduleFilter # type: ignore - from ._models import RoleEligibilityScheduleInstance # type: ignore - from ._models import RoleEligibilityScheduleInstanceFilter # type: ignore - from ._models import RoleEligibilityScheduleInstanceListResult # type: ignore - from ._models import RoleEligibilityScheduleListResult # type: ignore - from ._models import RoleEligibilityScheduleRequest # type: ignore - from ._models import RoleEligibilityScheduleRequestFilter # type: ignore - from ._models import RoleEligibilityScheduleRequestListResult # type: ignore - from ._models import RoleEligibilityScheduleRequestPropertiesScheduleInfo # type: ignore - from ._models import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration # type: ignore - from ._models import RoleEligibilityScheduleRequestPropertiesTicketInfo # type: ignore - from ._models import RoleManagementPolicy # type: ignore - from ._models import RoleManagementPolicyApprovalRule # type: ignore - from ._models import RoleManagementPolicyAssignment # type: ignore - from ._models import RoleManagementPolicyAssignmentListResult # type: ignore - from ._models import RoleManagementPolicyAuthenticationContextRule # type: ignore - from ._models import RoleManagementPolicyEnablementRule # type: ignore - from ._models import RoleManagementPolicyExpirationRule # type: ignore - from ._models import RoleManagementPolicyListResult # type: ignore - from ._models import RoleManagementPolicyNotificationRule # type: ignore - from ._models import RoleManagementPolicyRule # type: ignore - from ._models import RoleManagementPolicyRuleTarget # type: ignore - from ._models import UserSet # type: ignore - from ._models import ValidationResponse # type: ignore - from ._models import ValidationResponseErrorInfo # type: ignore +from ._models_py3 import ApprovalSettings +from ._models_py3 import ApprovalStage +from ._models_py3 import CloudErrorBody +from ._models_py3 import EligibleChildResource +from ._models_py3 import EligibleChildResourcesListResult +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExpandedProperties +from ._models_py3 import ExpandedPropertiesPrincipal +from ._models_py3 import ExpandedPropertiesRoleDefinition +from ._models_py3 import ExpandedPropertiesScope +from ._models_py3 import Permission +from ._models_py3 import PolicyAssignmentProperties +from ._models_py3 import PolicyAssignmentPropertiesPolicy +from ._models_py3 import PolicyAssignmentPropertiesRoleDefinition +from ._models_py3 import PolicyAssignmentPropertiesScope +from ._models_py3 import PolicyProperties +from ._models_py3 import PolicyPropertiesScope +from ._models_py3 import Principal +from ._models_py3 import RoleAssignment +from ._models_py3 import RoleAssignmentCreateParameters +from ._models_py3 import RoleAssignmentFilter +from ._models_py3 import RoleAssignmentListResult +from ._models_py3 import RoleAssignmentSchedule +from ._models_py3 import RoleAssignmentScheduleFilter +from ._models_py3 import RoleAssignmentScheduleInstance +from ._models_py3 import RoleAssignmentScheduleInstanceFilter +from ._models_py3 import RoleAssignmentScheduleInstanceListResult +from ._models_py3 import RoleAssignmentScheduleListResult +from ._models_py3 import RoleAssignmentScheduleRequest +from ._models_py3 import RoleAssignmentScheduleRequestFilter +from ._models_py3 import RoleAssignmentScheduleRequestListResult +from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfo +from ._models_py3 import RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration +from ._models_py3 import RoleAssignmentScheduleRequestPropertiesTicketInfo +from ._models_py3 import RoleEligibilitySchedule +from ._models_py3 import RoleEligibilityScheduleFilter +from ._models_py3 import RoleEligibilityScheduleInstance +from ._models_py3 import RoleEligibilityScheduleInstanceFilter +from ._models_py3 import RoleEligibilityScheduleInstanceListResult +from ._models_py3 import RoleEligibilityScheduleListResult +from ._models_py3 import RoleEligibilityScheduleRequest +from ._models_py3 import RoleEligibilityScheduleRequestFilter +from ._models_py3 import RoleEligibilityScheduleRequestListResult +from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfo +from ._models_py3 import RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration +from ._models_py3 import RoleEligibilityScheduleRequestPropertiesTicketInfo +from ._models_py3 import RoleManagementPolicy +from ._models_py3 import RoleManagementPolicyApprovalRule +from ._models_py3 import RoleManagementPolicyAssignment +from ._models_py3 import RoleManagementPolicyAssignmentListResult +from ._models_py3 import RoleManagementPolicyAuthenticationContextRule +from ._models_py3 import RoleManagementPolicyEnablementRule +from ._models_py3 import RoleManagementPolicyExpirationRule +from ._models_py3 import RoleManagementPolicyListResult +from ._models_py3 import RoleManagementPolicyNotificationRule +from ._models_py3 import RoleManagementPolicyRule +from ._models_py3 import RoleManagementPolicyRuleTarget +from ._models_py3 import UserSet +from ._models_py3 import ValidationResponse +from ._models_py3 import ValidationResponseErrorInfo + from ._authorization_management_client_enums import ( ApprovalMode, diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py index d6415a11e6d4..b3ec75ee17c0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_authorization_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ApprovalMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ApprovalMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of rule """ @@ -35,14 +20,14 @@ class ApprovalMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PARALLEL = "Parallel" NO_APPROVAL = "NoApproval" -class AssignmentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AssignmentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Assignment type of the role assignment schedule """ ACTIVATED = "Activated" ASSIGNED = "Assigned" -class EnablementRules(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EnablementRules(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of enable rules """ @@ -50,7 +35,7 @@ class EnablementRules(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): JUSTIFICATION = "Justification" TICKETING = "Ticketing" -class MemberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MemberType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Membership type of the role assignment schedule """ @@ -58,13 +43,13 @@ class MemberType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DIRECT = "Direct" GROUP = "Group" -class NotificationDeliveryMechanism(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationDeliveryMechanism(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of notification. """ EMAIL = "Email" -class NotificationLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NotificationLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The notification level. """ @@ -72,7 +57,7 @@ class NotificationLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CRITICAL = "Critical" ALL = "All" -class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The principal type of the assigned principal ID. """ @@ -82,7 +67,7 @@ class PrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FOREIGN_GROUP = "ForeignGroup" DEVICE = "Device" -class RecipientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecipientType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recipient type. """ @@ -90,7 +75,7 @@ class RecipientType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): APPROVER = "Approver" ADMIN = "Admin" -class RequestType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RequestType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc """ @@ -104,7 +89,7 @@ class RequestType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SELF_EXTEND = "SelfExtend" SELF_RENEW = "SelfRenew" -class RoleManagementPolicyRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleManagementPolicyRuleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of rule """ @@ -114,7 +99,7 @@ class RoleManagementPolicyRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, ROLE_MANAGEMENT_POLICY_EXPIRATION_RULE = "RoleManagementPolicyExpirationRule" ROLE_MANAGEMENT_POLICY_NOTIFICATION_RULE = "RoleManagementPolicyNotificationRule" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the role assignment schedule. """ @@ -141,7 +126,7 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SCHEDULE_CREATED = "ScheduleCreated" PENDING_EXTERNAL_PROVISIONING = "PendingExternalProvisioning" -class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Type of the role assignment schedule expiration """ @@ -149,7 +134,7 @@ class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AFTER_DATE_TIME = "AfterDateTime" NO_EXPIRATION = "NoExpiration" -class UserType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UserType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of user. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py deleted file mode 100644 index b4ab4b9b7c44..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models.py +++ /dev/null @@ -1,2581 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ApprovalSettings(msrest.serialization.Model): - """The approval settings. - - :param is_approval_required: Determine whether approval is required or not. - :type is_approval_required: bool - :param is_approval_required_for_extension: Determine whether approval is required for - assignment extension. - :type is_approval_required_for_extension: bool - :param is_requestor_justification_required: Determine whether requestor justification required. - :type is_requestor_justification_required: bool - :param approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", - "Parallel", "NoApproval". - :type approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode - :param approval_stages: The approval stages of the request. - :type approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] - """ - - _attribute_map = { - 'is_approval_required': {'key': 'isApprovalRequired', 'type': 'bool'}, - 'is_approval_required_for_extension': {'key': 'isApprovalRequiredForExtension', 'type': 'bool'}, - 'is_requestor_justification_required': {'key': 'isRequestorJustificationRequired', 'type': 'bool'}, - 'approval_mode': {'key': 'approvalMode', 'type': 'str'}, - 'approval_stages': {'key': 'approvalStages', 'type': '[ApprovalStage]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApprovalSettings, self).__init__(**kwargs) - self.is_approval_required = kwargs.get('is_approval_required', None) - self.is_approval_required_for_extension = kwargs.get('is_approval_required_for_extension', None) - self.is_requestor_justification_required = kwargs.get('is_requestor_justification_required', None) - self.approval_mode = kwargs.get('approval_mode', None) - self.approval_stages = kwargs.get('approval_stages', None) - - -class ApprovalStage(msrest.serialization.Model): - """The approval stage. - - :param approval_stage_time_out_in_days: The time in days when approval request would be timed - out. - :type approval_stage_time_out_in_days: int - :param is_approver_justification_required: Determine whether approver need to provide - justification for his decision. - :type is_approver_justification_required: bool - :param escalation_time_in_minutes: The time in minutes when the approval request would be - escalated if the primary approver does not approves. - :type escalation_time_in_minutes: int - :param primary_approvers: The primary approver of the request. - :type primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - :param is_escalation_enabled: The value determine whether escalation feature is enabled. - :type is_escalation_enabled: bool - :param escalation_approvers: The escalation approver of the request. - :type escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - """ - - _attribute_map = { - 'approval_stage_time_out_in_days': {'key': 'approvalStageTimeOutInDays', 'type': 'int'}, - 'is_approver_justification_required': {'key': 'isApproverJustificationRequired', 'type': 'bool'}, - 'escalation_time_in_minutes': {'key': 'escalationTimeInMinutes', 'type': 'int'}, - 'primary_approvers': {'key': 'primaryApprovers', 'type': '[UserSet]'}, - 'is_escalation_enabled': {'key': 'isEscalationEnabled', 'type': 'bool'}, - 'escalation_approvers': {'key': 'escalationApprovers', 'type': '[UserSet]'}, - } - - def __init__( - self, - **kwargs - ): - super(ApprovalStage, self).__init__(**kwargs) - self.approval_stage_time_out_in_days = kwargs.get('approval_stage_time_out_in_days', None) - self.is_approver_justification_required = kwargs.get('is_approver_justification_required', None) - self.escalation_time_in_minutes = kwargs.get('escalation_time_in_minutes', None) - self.primary_approvers = kwargs.get('primary_approvers', None) - self.is_escalation_enabled = kwargs.get('is_escalation_enabled', None) - self.escalation_approvers = kwargs.get('escalation_approvers', None) - - -class CloudErrorBody(msrest.serialization.Model): - """An error response from the service. - - :param code: An identifier for the error. Codes are invariant and are intended to be consumed - programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user - interface. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CloudErrorBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class EligibleChildResource(msrest.serialization.Model): - """Eligible child resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The resource scope Id. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EligibleChildResource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class EligibleChildResourcesListResult(msrest.serialization.Model): - """Eligible child resources list operation result. - - :param value: Eligible child resource list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EligibleChildResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EligibleChildResourcesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -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. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ExpandedProperties(msrest.serialization.Model): - """ExpandedProperties. - - :param scope: Details of the resource scope. - :type scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition - :param principal: Details of the principal. - :type principal: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal - """ - - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'ExpandedPropertiesScope'}, - 'role_definition': {'key': 'roleDefinition', 'type': 'ExpandedPropertiesRoleDefinition'}, - 'principal': {'key': 'principal', 'type': 'ExpandedPropertiesPrincipal'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandedProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.role_definition = kwargs.get('role_definition', None) - self.principal = kwargs.get('principal', None) - - -class ExpandedPropertiesPrincipal(msrest.serialization.Model): - """Details of the principal. - - :param id: Id of the principal. - :type id: str - :param display_name: Display name of the principal. - :type display_name: str - :param email: Email id of the principal. - :type email: str - :param type: Type of the principal. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandedPropertiesPrincipal, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.email = kwargs.get('email', None) - self.type = kwargs.get('type', None) - - -class ExpandedPropertiesRoleDefinition(msrest.serialization.Model): - """Details of role definition. - - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandedPropertiesRoleDefinition, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class ExpandedPropertiesScope(msrest.serialization.Model): - """Details of the resource scope. - - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ExpandedPropertiesScope, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class Permission(msrest.serialization.Model): - """Role definition permissions. - - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] - """ - - _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - 'data_actions': {'key': 'dataActions', 'type': '[str]'}, - 'not_data_actions': {'key': 'notDataActions', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Permission, self).__init__(**kwargs) - self.actions = kwargs.get('actions', None) - self.not_actions = kwargs.get('not_actions', None) - self.data_actions = kwargs.get('data_actions', None) - self.not_data_actions = kwargs.get('not_data_actions', None) - - -class PolicyAssignmentProperties(msrest.serialization.Model): - """PolicyAssignmentProperties. - - :param scope: Details of the resource scope. - :type scope: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition - :param policy: Details of the policy. - :type policy: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy - """ - - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'PolicyAssignmentPropertiesScope'}, - 'role_definition': {'key': 'roleDefinition', 'type': 'PolicyAssignmentPropertiesRoleDefinition'}, - 'policy': {'key': 'policy', 'type': 'PolicyAssignmentPropertiesPolicy'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyAssignmentProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.role_definition = kwargs.get('role_definition', None) - self.policy = kwargs.get('policy', None) - - -class PolicyAssignmentPropertiesPolicy(msrest.serialization.Model): - """Details of the policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Id of the policy. - :type id: str - :ivar last_modified_by: The name of the entity last modified it. - :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal - :param last_modified_date_time: The last modified date time. - :type last_modified_date_time: ~datetime.datetime - """ - - _validation = { - 'last_modified_by': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'Principal'}, - 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyAssignmentPropertiesPolicy, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.last_modified_by = None - self.last_modified_date_time = kwargs.get('last_modified_date_time', None) - - -class PolicyAssignmentPropertiesRoleDefinition(msrest.serialization.Model): - """Details of role definition. - - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyAssignmentPropertiesRoleDefinition, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class PolicyAssignmentPropertiesScope(msrest.serialization.Model): - """Details of the resource scope. - - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyAssignmentPropertiesScope, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class PolicyProperties(msrest.serialization.Model): - """PolicyProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar scope: Details of the resource scope. - :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyPropertiesScope - """ - - _validation = { - 'scope': {'readonly': True}, - } - - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'PolicyPropertiesScope'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyProperties, self).__init__(**kwargs) - self.scope = None - - -class PolicyPropertiesScope(msrest.serialization.Model): - """Details of the resource scope. - - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PolicyPropertiesScope, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - - -class Principal(msrest.serialization.Model): - """The name of the entity last modified it. - - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type email: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Principal, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.display_name = kwargs.get('display_name', None) - self.type = kwargs.get('type', None) - self.email = kwargs.get('email', None) - - -class RoleAssignment(msrest.serialization.Model): - """Role Assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment ID. - :vartype id: str - :ivar name: The role assignment name. - :vartype name: str - :ivar type: The role assignment type. - :vartype type: str - :ivar scope: The role assignment scope. - :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'scope': {'readonly': True}, - 'created_on': {'readonly': True}, - 'updated_on': {'readonly': True}, - 'created_by': {'readonly': True}, - 'updated_by': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'updated_by': {'key': 'properties.updatedBy', 'type': 'str'}, - 'delegated_managed_identity_resource_id': {'key': 'properties.delegatedManagedIdentityResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentCreateParameters(msrest.serialization.Model): - """Role assignment create parameters. - - 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 scope: The role assignment scope. - :vartype scope: str - :param role_definition_id: Required. The role definition ID. - :type role_definition_id: str - :param principal_id: Required. The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :ivar created_on: Time it was created. - :vartype created_on: ~datetime.datetime - :ivar updated_on: Time it was updated. - :vartype updated_on: ~datetime.datetime - :ivar created_by: Id of the user who created the assignment. - :vartype created_by: str - :ivar updated_by: Id of the user who updated the assignment. - :vartype updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str - """ - - _validation = { - 'scope': {'readonly': True}, - 'role_definition_id': {'required': True}, - 'principal_id': {'required': True}, - 'created_on': {'readonly': True}, - 'updated_on': {'readonly': True}, - 'created_by': {'readonly': True}, - 'updated_by': {'readonly': True}, - } - - _attribute_map = { - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, - 'created_by': {'key': 'properties.createdBy', 'type': 'str'}, - 'updated_by': {'key': 'properties.updatedBy', 'type': 'str'}, - 'delegated_managed_identity_resource_id': {'key': 'properties.delegatedManagedIdentityResourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentCreateParameters, self).__init__(**kwargs) - self.scope = None - self.role_definition_id = kwargs['role_definition_id'] - self.principal_id = kwargs['principal_id'] - self.principal_type = kwargs.get('principal_type', None) - self.description = kwargs.get('description', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.updated_on = None - self.created_by = None - self.updated_by = None - self.delegated_managed_identity_resource_id = kwargs.get('delegated_managed_identity_resource_id', None) - - -class RoleAssignmentFilter(msrest.serialization.Model): - """Role Assignments filter. - - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - - -class RoleAssignmentListResult(msrest.serialization.Model): - """Role assignment list operation result. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] - :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': '[RoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RoleAssignmentSchedule(msrest.serialization.Model): - """Role Assignment schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule Id. - :vartype id: str - :ivar name: The role assignment schedule name. - :vartype name: str - :ivar type: The role assignment schedule type. - :vartype type: str - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to - create this roleAssignmentSchedule. - :type role_assignment_schedule_request_id: str - :param linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated - this roleAssignmentSchedule. - :type linked_role_eligibility_schedule_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values - include: "Activated", "Assigned". - :type assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role assignment schedule. Possible values include: "Accepted", - "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role assignment schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role assignment schedule. - :type end_date_time: ~datetime.datetime - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role assignment schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'role_assignment_schedule_request_id': {'key': 'properties.roleAssignmentScheduleRequestId', 'type': 'str'}, - 'linked_role_eligibility_schedule_id': {'key': 'properties.linkedRoleEligibilityScheduleId', 'type': 'str'}, - 'assignment_type': {'key': 'properties.assignmentType', 'type': 'str'}, - 'member_type': {'key': 'properties.memberType', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, - 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentSchedule, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_assignment_schedule_request_id = kwargs.get('role_assignment_schedule_request_id', None) - self.linked_role_eligibility_schedule_id = kwargs.get('linked_role_eligibility_schedule_id', None) - self.assignment_type = kwargs.get('assignment_type', None) - self.member_type = kwargs.get('member_type', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.updated_on = kwargs.get('updated_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleAssignmentScheduleFilter(msrest.serialization.Model): - """Role assignment schedule filter. - - :param principal_id: Returns role assignment schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - - -class RoleAssignmentScheduleInstance(msrest.serialization.Model): - """Information about current or upcoming role assignment schedule instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule instance ID. - :vartype id: str - :ivar name: The role assignment schedule instance name. - :vartype name: str - :ivar type: The role assignment schedule instance type. - :vartype type: str - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_id: Id of the master role assignment schedule. - :type role_assignment_schedule_id: str - :param origin_role_assignment_id: Role Assignment Id in external system. - :type origin_role_assignment_id: str - :param status: The status of the role assignment schedule instance. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role assignment schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role assignment schedule instance. - :type end_date_time: ~datetime.datetime - :param linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :type linked_role_eligibility_schedule_id: str - :param linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked - to this roleAssignmentScheduleInstance. - :type linked_role_eligibility_schedule_instance_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values - include: "Activated", "Assigned". - :type assignment_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'role_assignment_schedule_id': {'key': 'properties.roleAssignmentScheduleId', 'type': 'str'}, - 'origin_role_assignment_id': {'key': 'properties.originRoleAssignmentId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - 'linked_role_eligibility_schedule_id': {'key': 'properties.linkedRoleEligibilityScheduleId', 'type': 'str'}, - 'linked_role_eligibility_schedule_instance_id': {'key': 'properties.linkedRoleEligibilityScheduleInstanceId', 'type': 'str'}, - 'assignment_type': {'key': 'properties.assignmentType', 'type': 'str'}, - 'member_type': {'key': 'properties.memberType', 'type': 'str'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_assignment_schedule_id = kwargs.get('role_assignment_schedule_id', None) - self.origin_role_assignment_id = kwargs.get('origin_role_assignment_id', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.linked_role_eligibility_schedule_id = kwargs.get('linked_role_eligibility_schedule_id', None) - self.linked_role_eligibility_schedule_instance_id = kwargs.get('linked_role_eligibility_schedule_instance_id', None) - self.assignment_type = kwargs.get('assignment_type', None) - self.member_type = kwargs.get('member_type', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleAssignmentScheduleInstanceFilter(msrest.serialization.Model): - """Role assignment schedule instance filter. - - :param principal_id: Returns role assignment schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule instances of the specific role - definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str - :param role_assignment_schedule_id: Returns role assignment schedule instances belonging to a - specific role assignment schedule. - :type role_assignment_schedule_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'role_assignment_schedule_id': {'key': 'roleAssignmentScheduleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleInstanceFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - self.role_assignment_schedule_id = kwargs.get('role_assignment_schedule_id', None) - - -class RoleAssignmentScheduleInstanceListResult(msrest.serialization.Model): - """Role assignment schedule instance list operation result. - - :param value: Role assignment schedule instance list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignmentScheduleInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentScheduleListResult(msrest.serialization.Model): - """Role assignment schedule list operation result. - - :param value: Role assignment schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignmentSchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentScheduleRequest(msrest.serialization.Model): - """Role Assignment schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment schedule request ID. - :vartype id: str - :ivar name: The role assignment schedule request name. - :vartype name: str - :ivar type: The role assignment schedule request type. - :vartype type: str - :ivar scope: The role assignment schedule request scope. - :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Possible values include: - "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", - "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role assignment schedule request. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar approval_id: The approvalId of the role assignment schedule request. - :vartype approval_id: str - :param target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :type target_role_assignment_schedule_id: str - :param target_role_assignment_schedule_instance_id: The role assignment schedule instance id - being updated. - :type target_role_assignment_schedule_instance_id: str - :param schedule_info: Schedule info of the role assignment schedule. - :type schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :param linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to - activate an eligibility. - :type linked_role_eligibility_schedule_id: str - :param justification: Justification for the role assignment. - :type justification: str - :param ticket_info: Ticket Info of the role assignment. - :type ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :ivar created_on: DateTime when role assignment schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'scope': {'readonly': True}, - 'principal_type': {'readonly': True}, - 'status': {'readonly': True}, - 'approval_id': {'readonly': True}, - 'created_on': {'readonly': True}, - 'requestor_id': {'readonly': True}, - 'expanded_properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'request_type': {'key': 'properties.requestType', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'approval_id': {'key': 'properties.approvalId', 'type': 'str'}, - 'target_role_assignment_schedule_id': {'key': 'properties.targetRoleAssignmentScheduleId', 'type': 'str'}, - 'target_role_assignment_schedule_instance_id': {'key': 'properties.targetRoleAssignmentScheduleInstanceId', 'type': 'str'}, - 'schedule_info': {'key': 'properties.scheduleInfo', 'type': 'RoleAssignmentScheduleRequestPropertiesScheduleInfo'}, - 'linked_role_eligibility_schedule_id': {'key': 'properties.linkedRoleEligibilityScheduleId', 'type': 'str'}, - 'justification': {'key': 'properties.justification', 'type': 'str'}, - 'ticket_info': {'key': 'properties.ticketInfo', 'type': 'RoleAssignmentScheduleRequestPropertiesTicketInfo'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'requestor_id': {'key': 'properties.requestorId', 'type': 'str'}, - 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequest, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - self.request_type = kwargs.get('request_type', None) - self.status = None - self.approval_id = None - self.target_role_assignment_schedule_id = kwargs.get('target_role_assignment_schedule_id', None) - self.target_role_assignment_schedule_instance_id = kwargs.get('target_role_assignment_schedule_instance_id', None) - self.schedule_info = kwargs.get('schedule_info', None) - self.linked_role_eligibility_schedule_id = kwargs.get('linked_role_eligibility_schedule_id', None) - self.justification = kwargs.get('justification', None) - self.ticket_info = kwargs.get('ticket_info', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleAssignmentScheduleRequestFilter(msrest.serialization.Model): - """Role assignment schedule request filter. - - :param principal_id: Returns role assignment requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role assignment requests created by specific principal. - :type requestor_id: str - :param status: Returns role assignment requests of specific status. - :type status: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'requestor_id': {'key': 'requestorId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.requestor_id = kwargs.get('requestor_id', None) - self.status = kwargs.get('status', None) - - -class RoleAssignmentScheduleRequestListResult(msrest.serialization.Model): - """Role assignment schedule request list operation result. - - :param value: Role assignment schedule request list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleAssignmentScheduleRequest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): - """Schedule info of the role assignment schedule. - - :param start_date_time: Start DateTime of the role assignment schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role assignment schedule. - :type expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, - 'expiration': {'key': 'expiration', 'type': 'RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) - self.start_date_time = kwargs.get('start_date_time', None) - self.expiration = kwargs.get('expiration', None) - - -class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): - """Expiration of the role assignment schedule. - - :param type: Type of the role assignment schedule expiration. Possible values include: - "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role assignment schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role assignment schedule in TimeSpan. - :type duration: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'end_date_time': {'key': 'endDateTime', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.duration = kwargs.get('duration', None) - - -class RoleAssignmentScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): - """Ticket Info of the role assignment. - - :param ticket_number: Ticket number for the role assignment. - :type ticket_number: str - :param ticket_system: Ticket system name for the role assignment. - :type ticket_system: str - """ - - _attribute_map = { - 'ticket_number': {'key': 'ticketNumber', 'type': 'str'}, - 'ticket_system': {'key': 'ticketSystem', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) - self.ticket_number = kwargs.get('ticket_number', None) - self.ticket_system = kwargs.get('ticket_system', None) - - -class RoleEligibilitySchedule(msrest.serialization.Model): - """Role eligibility schedule. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule Id. - :vartype id: str - :ivar name: The role eligibility schedule name. - :vartype name: str - :ivar type: The role eligibility schedule type. - :vartype type: str - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to - create this roleAssignmentSchedule. - :type role_eligibility_schedule_request_id: str - :param member_type: Membership type of the role eligibility schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role eligibility schedule. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role eligibility schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'role_eligibility_schedule_request_id': {'key': 'properties.roleEligibilityScheduleRequestId', 'type': 'str'}, - 'member_type': {'key': 'properties.memberType', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'updated_on': {'key': 'properties.updatedOn', 'type': 'iso-8601'}, - 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilitySchedule, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_eligibility_schedule_request_id = kwargs.get('role_eligibility_schedule_request_id', None) - self.member_type = kwargs.get('member_type', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.updated_on = kwargs.get('updated_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleEligibilityScheduleFilter(msrest.serialization.Model): - """Role eligibility schedule filter. - - :param principal_id: Returns role eligibility schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule of the specific status. - :type status: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - - -class RoleEligibilityScheduleInstance(msrest.serialization.Model): - """Information about current or upcoming role eligibility schedule instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule instance ID. - :vartype id: str - :ivar name: The role eligibility schedule instance name. - :vartype name: str - :ivar type: The role eligibility schedule instance type. - :vartype type: str - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_id: Id of the master role eligibility schedule. - :type role_eligibility_schedule_id: str - :param status: The status of the role eligibility schedule instance. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role eligibility schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role eligibility schedule instance. - :type end_date_time: ~datetime.datetime - :param member_type: Membership type of the role eligibility schedule. Possible values include: - "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'role_eligibility_schedule_id': {'key': 'properties.roleEligibilityScheduleId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - 'member_type': {'key': 'properties.memberType', 'type': 'str'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = kwargs.get('principal_type', None) - self.role_eligibility_schedule_id = kwargs.get('role_eligibility_schedule_id', None) - self.status = kwargs.get('status', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.member_type = kwargs.get('member_type', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = kwargs.get('created_on', None) - self.expanded_properties = kwargs.get('expanded_properties', None) - - -class RoleEligibilityScheduleInstanceFilter(msrest.serialization.Model): - """Role eligibility schedule instance filter. - - :param principal_id: Returns role eligibility schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule instances of the specific role - definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule instances of the specific status. - :type status: str - :param role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a - specific role eligibility schedule. - :type role_eligibility_schedule_id: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'role_eligibility_schedule_id': {'key': 'roleEligibilityScheduleId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleInstanceFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.status = kwargs.get('status', None) - self.role_eligibility_schedule_id = kwargs.get('role_eligibility_schedule_id', None) - - -class RoleEligibilityScheduleInstanceListResult(msrest.serialization.Model): - """Role eligibility schedule instance list operation result. - - :param value: Role eligibility schedule instance list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleEligibilityScheduleInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleEligibilityScheduleListResult(msrest.serialization.Model): - """role eligibility schedule list operation result. - - :param value: role eligibility schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleEligibilitySchedule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleEligibilityScheduleRequest(msrest.serialization.Model): - """Role Eligibility schedule request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role eligibility schedule request ID. - :vartype id: str - :ivar name: The role eligibility schedule request name. - :vartype name: str - :ivar type: The role eligibility schedule request type. - :vartype type: str - :ivar scope: The role eligibility schedule request scope. - :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :ivar principal_type: The principal type of the assigned principal ID. Possible values include: - "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, - AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", - "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType - :ivar status: The status of the role eligibility schedule request. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", - "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", - "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", - "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", - "ScheduleCreated", "PendingExternalProvisioning". - :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :ivar approval_id: The approvalId of the role eligibility schedule request. - :vartype approval_id: str - :param schedule_info: Schedule info of the role eligibility schedule. - :type schedule_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :param target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the - role eligibility schedule id being updated. - :type target_role_eligibility_schedule_id: str - :param target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id - being updated. - :type target_role_eligibility_schedule_instance_id: str - :param justification: Justification for the role eligibility. - :type justification: str - :param ticket_info: Ticket Info of the role eligibility. - :type ticket_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :param condition: The conditions on the role assignment. This limits the resources it can be - assigned to. e.g.: - @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] - StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :ivar created_on: DateTime when role eligibility schedule request was created. - :vartype created_on: ~datetime.datetime - :ivar requestor_id: Id of the user who created this request. - :vartype requestor_id: str - :ivar expanded_properties: Additional properties of principal, scope and role definition. - :vartype expanded_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'scope': {'readonly': True}, - 'principal_type': {'readonly': True}, - 'status': {'readonly': True}, - 'approval_id': {'readonly': True}, - 'created_on': {'readonly': True}, - 'requestor_id': {'readonly': True}, - 'expanded_properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.principalType', 'type': 'str'}, - 'request_type': {'key': 'properties.requestType', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'approval_id': {'key': 'properties.approvalId', 'type': 'str'}, - 'schedule_info': {'key': 'properties.scheduleInfo', 'type': 'RoleEligibilityScheduleRequestPropertiesScheduleInfo'}, - 'target_role_eligibility_schedule_id': {'key': 'properties.targetRoleEligibilityScheduleId', 'type': 'str'}, - 'target_role_eligibility_schedule_instance_id': {'key': 'properties.targetRoleEligibilityScheduleInstanceId', 'type': 'str'}, - 'justification': {'key': 'properties.justification', 'type': 'str'}, - 'ticket_info': {'key': 'properties.ticketInfo', 'type': 'RoleEligibilityScheduleRequestPropertiesTicketInfo'}, - 'condition': {'key': 'properties.condition', 'type': 'str'}, - 'condition_version': {'key': 'properties.conditionVersion', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'iso-8601'}, - 'requestor_id': {'key': 'properties.requestorId', 'type': 'str'}, - 'expanded_properties': {'key': 'properties.expandedProperties', 'type': 'ExpandedProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequest, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = None - self.role_definition_id = kwargs.get('role_definition_id', None) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - self.request_type = kwargs.get('request_type', None) - self.status = None - self.approval_id = None - self.schedule_info = kwargs.get('schedule_info', None) - self.target_role_eligibility_schedule_id = kwargs.get('target_role_eligibility_schedule_id', None) - self.target_role_eligibility_schedule_instance_id = kwargs.get('target_role_eligibility_schedule_instance_id', None) - self.justification = kwargs.get('justification', None) - self.ticket_info = kwargs.get('ticket_info', None) - self.condition = kwargs.get('condition', None) - self.condition_version = kwargs.get('condition_version', None) - self.created_on = None - self.requestor_id = None - self.expanded_properties = None - - -class RoleEligibilityScheduleRequestFilter(msrest.serialization.Model): - """Role eligibility schedule request filter. - - :param principal_id: Returns role eligibility requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role eligibility requests created by specific principal. - :type requestor_id: str - :param status: Returns role eligibility requests of specific status. - :type status: str - """ - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'role_definition_id': {'key': 'roleDefinitionId', 'type': 'str'}, - 'requestor_id': {'key': 'requestorId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestFilter, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.requestor_id = kwargs.get('requestor_id', None) - self.status = kwargs.get('status', None) - - -class RoleEligibilityScheduleRequestListResult(msrest.serialization.Model): - """Role eligibility schedule request list operation result. - - :param value: Role eligibility schedule request list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleEligibilityScheduleRequest]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): - """Schedule info of the role eligibility schedule. - - :param start_date_time: Start DateTime of the role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role eligibility schedule. - :type expiration: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration - """ - - _attribute_map = { - 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, - 'expiration': {'key': 'expiration', 'type': 'RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) - self.start_date_time = kwargs.get('start_date_time', None) - self.expiration = kwargs.get('expiration', None) - - -class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): - """Expiration of the role eligibility schedule. - - :param type: Type of the role eligibility schedule expiration. Possible values include: - "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role eligibility schedule in TimeSpan. - :type duration: str - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'end_date_time': {'key': 'endDateTime', 'type': 'iso-8601'}, - 'duration': {'key': 'duration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.end_date_time = kwargs.get('end_date_time', None) - self.duration = kwargs.get('duration', None) - - -class RoleEligibilityScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): - """Ticket Info of the role eligibility. - - :param ticket_number: Ticket number for the role eligibility. - :type ticket_number: str - :param ticket_system: Ticket system name for the role eligibility. - :type ticket_system: str - """ - - _attribute_map = { - 'ticket_number': {'key': 'ticketNumber', 'type': 'str'}, - 'ticket_system': {'key': 'ticketSystem', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleEligibilityScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) - self.ticket_number = kwargs.get('ticket_number', None) - self.ticket_system = kwargs.get('ticket_system', None) - - -class RoleManagementPolicy(msrest.serialization.Model): - """Role management policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role management policy Id. - :vartype id: str - :ivar name: The role management policy name. - :vartype name: str - :ivar type: The role management policy type. - :vartype type: str - :param scope: The role management policy scope. - :type scope: str - :param display_name: The role management policy display name. - :type display_name: str - :param description: The role management policy description. - :type description: str - :param is_organization_default: The role management policy is default policy. - :type is_organization_default: bool - :ivar last_modified_by: The name of the entity last modified it. - :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal - :ivar last_modified_date_time: The last modified date time. - :vartype last_modified_date_time: ~datetime.datetime - :param rules: The rule applied to the policy. - :type rules: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] - :ivar effective_rules: The readonly computed rule applied to the policy. - :vartype effective_rules: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] - :ivar policy_properties: Additional properties of scope. - :vartype policy_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'last_modified_date_time': {'readonly': True}, - 'effective_rules': {'readonly': True}, - 'policy_properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'is_organization_default': {'key': 'properties.isOrganizationDefault', 'type': 'bool'}, - 'last_modified_by': {'key': 'properties.lastModifiedBy', 'type': 'Principal'}, - 'last_modified_date_time': {'key': 'properties.lastModifiedDateTime', 'type': 'iso-8601'}, - 'rules': {'key': 'properties.rules', 'type': '[RoleManagementPolicyRule]'}, - 'effective_rules': {'key': 'properties.effectiveRules', 'type': '[RoleManagementPolicyRule]'}, - 'policy_properties': {'key': 'properties.policyProperties', 'type': 'PolicyProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicy, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.display_name = kwargs.get('display_name', None) - self.description = kwargs.get('description', None) - self.is_organization_default = kwargs.get('is_organization_default', None) - self.last_modified_by = None - self.last_modified_date_time = None - self.rules = kwargs.get('rules', None) - self.effective_rules = None - self.policy_properties = None - - -class RoleManagementPolicyRule(msrest.serialization.Model): - """The role management policy rule. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: RoleManagementPolicyApprovalRule, RoleManagementPolicyAuthenticationContextRule, RoleManagementPolicyEnablementRule, RoleManagementPolicyExpirationRule, RoleManagementPolicyNotificationRule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - """ - - _validation = { - 'rule_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rule_type': {'key': 'ruleType', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, - } - - _subtype_map = { - 'rule_type': {'RoleManagementPolicyApprovalRule': 'RoleManagementPolicyApprovalRule', 'RoleManagementPolicyAuthenticationContextRule': 'RoleManagementPolicyAuthenticationContextRule', 'RoleManagementPolicyEnablementRule': 'RoleManagementPolicyEnablementRule', 'RoleManagementPolicyExpirationRule': 'RoleManagementPolicyExpirationRule', 'RoleManagementPolicyNotificationRule': 'RoleManagementPolicyNotificationRule'} - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyRule, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.rule_type = None # type: Optional[str] - self.target = kwargs.get('target', None) - - -class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param setting: The approval setting. - :type setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings - """ - - _validation = { - 'rule_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rule_type': {'key': 'ruleType', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, - 'setting': {'key': 'setting', 'type': 'ApprovalSettings'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyApprovalRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyApprovalRule' # type: str - self.setting = kwargs.get('setting', None) - - -class RoleManagementPolicyAssignment(msrest.serialization.Model): - """Role management policy. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role management policy Id. - :vartype id: str - :ivar name: The role management policy name. - :vartype name: str - :ivar type: The role management policy type. - :vartype type: str - :param scope: The role management policy scope. - :type scope: str - :param role_definition_id: The role definition of management policy assignment. - :type role_definition_id: str - :param policy_id: The policy id role management policy assignment. - :type policy_id: str - :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. - :vartype policy_assignment_properties: - ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_assignment_properties': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'policy_assignment_properties': {'key': 'properties.policyAssignmentProperties', 'type': 'PolicyAssignmentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyAssignment, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.scope = kwargs.get('scope', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.policy_id = kwargs.get('policy_id', None) - self.policy_assignment_properties = None - - -class RoleManagementPolicyAssignmentListResult(msrest.serialization.Model): - """Role management policy assignment list operation result. - - :param value: Role management policy assignment list. - :type value: - list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleManagementPolicyAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyAssignmentListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_enabled: The value indicating if rule is enabled. - :type is_enabled: bool - :param claim_value: The claim value. - :type claim_value: str - """ - - _validation = { - 'rule_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rule_type': {'key': 'ruleType', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, - 'is_enabled': {'key': 'isEnabled', 'type': 'bool'}, - 'claim_value': {'key': 'claimValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyAuthenticationContextRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyAuthenticationContextRule' # type: str - self.is_enabled = kwargs.get('is_enabled', None) - self.claim_value = kwargs.get('claim_value', None) - - -class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param enabled_rules: The list of enabled rules. - :type enabled_rules: list[str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] - """ - - _validation = { - 'rule_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rule_type': {'key': 'ruleType', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, - 'enabled_rules': {'key': 'enabledRules', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyEnablementRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyEnablementRule' # type: str - self.enabled_rules = kwargs.get('enabled_rules', None) - - -class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_expiration_required: The value indicating whether expiration is required. - :type is_expiration_required: bool - :param maximum_duration: The maximum duration of expiration in timespan. - :type maximum_duration: str - """ - - _validation = { - 'rule_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rule_type': {'key': 'ruleType', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, - 'is_expiration_required': {'key': 'isExpirationRequired', 'type': 'bool'}, - 'maximum_duration': {'key': 'maximumDuration', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyExpirationRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyExpirationRule' # type: str - self.is_expiration_required = kwargs.get('is_expiration_required', None) - self.maximum_duration = kwargs.get('maximum_duration', None) - - -class RoleManagementPolicyListResult(msrest.serialization.Model): - """Role management policy list operation result. - - :param value: Role management policy list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[RoleManagementPolicy]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): - """The role management policy rule. - - All required parameters must be populated in order to send to Azure. - - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", - "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", - "RoleManagementPolicyNotificationRule". - :type rule_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: - ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param notification_type: The type of notification. Possible values include: "Email". - :type notification_type: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism - :param notification_level: The notification level. Possible values include: "None", "Critical", - "All". - :type notification_level: str or - ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel - :param recipient_type: The recipient type. Possible values include: "Requestor", "Approver", - "Admin". - :type recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType - :param notification_recipients: The list notification recipients. - :type notification_recipients: list[str] - :param is_default_recipients_enabled: Its value determine if the notification need to be sent - to the recipient type specified in policy rule. - :type is_default_recipients_enabled: bool - """ - - _validation = { - 'rule_type': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'rule_type': {'key': 'ruleType', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'RoleManagementPolicyRuleTarget'}, - 'notification_type': {'key': 'notificationType', 'type': 'str'}, - 'notification_level': {'key': 'notificationLevel', 'type': 'str'}, - 'recipient_type': {'key': 'recipientType', 'type': 'str'}, - 'notification_recipients': {'key': 'notificationRecipients', 'type': '[str]'}, - 'is_default_recipients_enabled': {'key': 'isDefaultRecipientsEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyNotificationRule, self).__init__(**kwargs) - self.rule_type = 'RoleManagementPolicyNotificationRule' # type: str - self.notification_type = kwargs.get('notification_type', None) - self.notification_level = kwargs.get('notification_level', None) - self.recipient_type = kwargs.get('recipient_type', None) - self.notification_recipients = kwargs.get('notification_recipients', None) - self.is_default_recipients_enabled = kwargs.get('is_default_recipients_enabled', None) - - -class RoleManagementPolicyRuleTarget(msrest.serialization.Model): - """The role management policy rule target. - - :param caller: The caller of the setting. - :type caller: str - :param operations: The type of operation. - :type operations: list[str] - :param level: The assignment level to which it is applied. - :type level: str - :param target_objects: The list of target objects. - :type target_objects: list[str] - :param inheritable_settings: The list of inheritable settings. - :type inheritable_settings: list[str] - :param enforced_settings: The list of enforced settings. - :type enforced_settings: list[str] - """ - - _attribute_map = { - 'caller': {'key': 'caller', 'type': 'str'}, - 'operations': {'key': 'operations', 'type': '[str]'}, - 'level': {'key': 'level', 'type': 'str'}, - 'target_objects': {'key': 'targetObjects', 'type': '[str]'}, - 'inheritable_settings': {'key': 'inheritableSettings', 'type': '[str]'}, - 'enforced_settings': {'key': 'enforcedSettings', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleManagementPolicyRuleTarget, self).__init__(**kwargs) - self.caller = kwargs.get('caller', None) - self.operations = kwargs.get('operations', None) - self.level = kwargs.get('level', None) - self.target_objects = kwargs.get('target_objects', None) - self.inheritable_settings = kwargs.get('inheritable_settings', None) - self.enforced_settings = kwargs.get('enforced_settings', None) - - -class UserSet(msrest.serialization.Model): - """The detail of a user. - - :param user_type: The type of user. Possible values include: "User", "Group". - :type user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType - :param is_backup: The value indicating whether the user is a backup fallback approver. - :type is_backup: bool - :param id: The object id of the user. - :type id: str - :param description: The description of the user. - :type description: str - """ - - _attribute_map = { - 'user_type': {'key': 'userType', 'type': 'str'}, - 'is_backup': {'key': 'isBackup', 'type': 'bool'}, - 'id': {'key': 'id', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(UserSet, self).__init__(**kwargs) - self.user_type = kwargs.get('user_type', None) - self.is_backup = kwargs.get('is_backup', None) - self.id = kwargs.get('id', None) - self.description = kwargs.get('description', None) - - -class ValidationResponse(msrest.serialization.Model): - """Validation response. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_valid: Whether or not validation succeeded. - :vartype is_valid: bool - :param error_info: Failed validation result details. - :type error_info: - ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo - """ - - _validation = { - 'is_valid': {'readonly': True}, - } - - _attribute_map = { - 'is_valid': {'key': 'isValid', 'type': 'bool'}, - 'error_info': {'key': 'errorInfo', 'type': 'ValidationResponseErrorInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidationResponse, self).__init__(**kwargs) - self.is_valid = None - self.error_info = kwargs.get('error_info', None) - - -class ValidationResponseErrorInfo(msrest.serialization.Model): - """Failed validation result details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code indicating why validation failed. - :vartype code: str - :ivar message: Message indicating why validation failed. - :vartype message: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidationResponseErrorInfo, self).__init__(**kwargs) - self.code = None - self.message = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py index f56a5d95927c..042795b2e211 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/models/_models_py3.py @@ -18,18 +18,20 @@ class ApprovalSettings(msrest.serialization.Model): """The approval settings. - :param is_approval_required: Determine whether approval is required or not. - :type is_approval_required: bool - :param is_approval_required_for_extension: Determine whether approval is required for - assignment extension. - :type is_approval_required_for_extension: bool - :param is_requestor_justification_required: Determine whether requestor justification required. - :type is_requestor_justification_required: bool - :param approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", + :ivar is_approval_required: Determine whether approval is required or not. + :vartype is_approval_required: bool + :ivar is_approval_required_for_extension: Determine whether approval is required for assignment + extension. + :vartype is_approval_required_for_extension: bool + :ivar is_requestor_justification_required: Determine whether requestor justification required. + :vartype is_requestor_justification_required: bool + :ivar approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", "Parallel", "NoApproval". - :type approval_mode: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode - :param approval_stages: The approval stages of the request. - :type approval_stages: list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] + :vartype approval_mode: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode + :ivar approval_stages: The approval stages of the request. + :vartype approval_stages: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] """ _attribute_map = { @@ -50,6 +52,23 @@ def __init__( approval_stages: Optional[List["ApprovalStage"]] = None, **kwargs ): + """ + :keyword is_approval_required: Determine whether approval is required or not. + :paramtype is_approval_required: bool + :keyword is_approval_required_for_extension: Determine whether approval is required for + assignment extension. + :paramtype is_approval_required_for_extension: bool + :keyword is_requestor_justification_required: Determine whether requestor justification + required. + :paramtype is_requestor_justification_required: bool + :keyword approval_mode: The type of rule. Possible values include: "SingleStage", "Serial", + "Parallel", "NoApproval". + :paramtype approval_mode: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalMode + :keyword approval_stages: The approval stages of the request. + :paramtype approval_stages: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalStage] + """ super(ApprovalSettings, self).__init__(**kwargs) self.is_approval_required = is_approval_required self.is_approval_required_for_extension = is_approval_required_for_extension @@ -61,21 +80,22 @@ def __init__( class ApprovalStage(msrest.serialization.Model): """The approval stage. - :param approval_stage_time_out_in_days: The time in days when approval request would be timed + :ivar approval_stage_time_out_in_days: The time in days when approval request would be timed out. - :type approval_stage_time_out_in_days: int - :param is_approver_justification_required: Determine whether approver need to provide + :vartype approval_stage_time_out_in_days: int + :ivar is_approver_justification_required: Determine whether approver need to provide justification for his decision. - :type is_approver_justification_required: bool - :param escalation_time_in_minutes: The time in minutes when the approval request would be + :vartype is_approver_justification_required: bool + :ivar escalation_time_in_minutes: The time in minutes when the approval request would be escalated if the primary approver does not approves. - :type escalation_time_in_minutes: int - :param primary_approvers: The primary approver of the request. - :type primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] - :param is_escalation_enabled: The value determine whether escalation feature is enabled. - :type is_escalation_enabled: bool - :param escalation_approvers: The escalation approver of the request. - :type escalation_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] + :vartype escalation_time_in_minutes: int + :ivar primary_approvers: The primary approver of the request. + :vartype primary_approvers: list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] + :ivar is_escalation_enabled: The value determine whether escalation feature is enabled. + :vartype is_escalation_enabled: bool + :ivar escalation_approvers: The escalation approver of the request. + :vartype escalation_approvers: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] """ _attribute_map = { @@ -98,6 +118,25 @@ def __init__( escalation_approvers: Optional[List["UserSet"]] = None, **kwargs ): + """ + :keyword approval_stage_time_out_in_days: The time in days when approval request would be timed + out. + :paramtype approval_stage_time_out_in_days: int + :keyword is_approver_justification_required: Determine whether approver need to provide + justification for his decision. + :paramtype is_approver_justification_required: bool + :keyword escalation_time_in_minutes: The time in minutes when the approval request would be + escalated if the primary approver does not approves. + :paramtype escalation_time_in_minutes: int + :keyword primary_approvers: The primary approver of the request. + :paramtype primary_approvers: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] + :keyword is_escalation_enabled: The value determine whether escalation feature is enabled. + :paramtype is_escalation_enabled: bool + :keyword escalation_approvers: The escalation approver of the request. + :paramtype escalation_approvers: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.UserSet] + """ super(ApprovalStage, self).__init__(**kwargs) self.approval_stage_time_out_in_days = approval_stage_time_out_in_days self.is_approver_justification_required = is_approver_justification_required @@ -110,12 +149,12 @@ def __init__( class CloudErrorBody(msrest.serialization.Model): """An error response from the service. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for display in a user + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user interface. - :type message: str + :vartype message: str """ _attribute_map = { @@ -130,6 +169,14 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -164,6 +211,8 @@ def __init__( self, **kwargs ): + """ + """ super(EligibleChildResource, self).__init__(**kwargs) self.id = None self.name = None @@ -173,10 +222,11 @@ def __init__( class EligibleChildResourcesListResult(msrest.serialization.Model): """Eligible child resources list operation result. - :param value: Eligible child resource list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Eligible child resource list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -191,6 +241,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Eligible child resource list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(EligibleChildResourcesListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -221,6 +278,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -264,6 +323,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -275,8 +336,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail """ _attribute_map = { @@ -289,6 +350,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.authorization.v2020_10_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -296,13 +361,13 @@ def __init__( class ExpandedProperties(msrest.serialization.Model): """ExpandedProperties. - :param scope: Details of the resource scope. - :type scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope + :ivar role_definition: Details of role definition. + :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition - :param principal: Details of the principal. - :type principal: + :ivar principal: Details of the principal. + :vartype principal: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal """ @@ -320,6 +385,16 @@ def __init__( principal: Optional["ExpandedPropertiesPrincipal"] = None, **kwargs ): + """ + :keyword scope: Details of the resource scope. + :paramtype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesScope + :keyword role_definition: Details of role definition. + :paramtype role_definition: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesRoleDefinition + :keyword principal: Details of the principal. + :paramtype principal: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedPropertiesPrincipal + """ super(ExpandedProperties, self).__init__(**kwargs) self.scope = scope self.role_definition = role_definition @@ -329,14 +404,14 @@ def __init__( class ExpandedPropertiesPrincipal(msrest.serialization.Model): """Details of the principal. - :param id: Id of the principal. - :type id: str - :param display_name: Display name of the principal. - :type display_name: str - :param email: Email id of the principal. - :type email: str - :param type: Type of the principal. - :type type: str + :ivar id: Id of the principal. + :vartype id: str + :ivar display_name: Display name of the principal. + :vartype display_name: str + :ivar email: Email id of the principal. + :vartype email: str + :ivar type: Type of the principal. + :vartype type: str """ _attribute_map = { @@ -355,6 +430,16 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: Id of the principal. + :paramtype id: str + :keyword display_name: Display name of the principal. + :paramtype display_name: str + :keyword email: Email id of the principal. + :paramtype email: str + :keyword type: Type of the principal. + :paramtype type: str + """ super(ExpandedPropertiesPrincipal, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -365,12 +450,12 @@ def __init__( class ExpandedPropertiesRoleDefinition(msrest.serialization.Model): """Details of role definition. - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str + :ivar id: Id of the role definition. + :vartype id: str + :ivar display_name: Display name of the role definition. + :vartype display_name: str + :ivar type: Type of the role definition. + :vartype type: str """ _attribute_map = { @@ -387,6 +472,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: Id of the role definition. + :paramtype id: str + :keyword display_name: Display name of the role definition. + :paramtype display_name: str + :keyword type: Type of the role definition. + :paramtype type: str + """ super(ExpandedPropertiesRoleDefinition, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -396,12 +489,12 @@ def __init__( class ExpandedPropertiesScope(msrest.serialization.Model): """Details of the resource scope. - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str """ _attribute_map = { @@ -418,6 +511,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ super(ExpandedPropertiesScope, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -427,14 +528,14 @@ def __init__( class Permission(msrest.serialization.Model): """Role definition permissions. - :param actions: Allowed actions. - :type actions: list[str] - :param not_actions: Denied actions. - :type not_actions: list[str] - :param data_actions: Allowed Data actions. - :type data_actions: list[str] - :param not_data_actions: Denied Data actions. - :type not_data_actions: list[str] + :ivar actions: Allowed actions. + :vartype actions: list[str] + :ivar not_actions: Denied actions. + :vartype not_actions: list[str] + :ivar data_actions: Allowed Data actions. + :vartype data_actions: list[str] + :ivar not_data_actions: Denied Data actions. + :vartype not_data_actions: list[str] """ _attribute_map = { @@ -453,6 +554,16 @@ def __init__( not_data_actions: Optional[List[str]] = None, **kwargs ): + """ + :keyword actions: Allowed actions. + :paramtype actions: list[str] + :keyword not_actions: Denied actions. + :paramtype not_actions: list[str] + :keyword data_actions: Allowed Data actions. + :paramtype data_actions: list[str] + :keyword not_data_actions: Denied Data actions. + :paramtype not_data_actions: list[str] + """ super(Permission, self).__init__(**kwargs) self.actions = actions self.not_actions = not_actions @@ -463,14 +574,14 @@ def __init__( class PolicyAssignmentProperties(msrest.serialization.Model): """PolicyAssignmentProperties. - :param scope: Details of the resource scope. - :type scope: + :ivar scope: Details of the resource scope. + :vartype scope: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope - :param role_definition: Details of role definition. - :type role_definition: + :ivar role_definition: Details of role definition. + :vartype role_definition: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition - :param policy: Details of the policy. - :type policy: + :ivar policy: Details of the policy. + :vartype policy: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy """ @@ -488,6 +599,17 @@ def __init__( policy: Optional["PolicyAssignmentPropertiesPolicy"] = None, **kwargs ): + """ + :keyword scope: Details of the resource scope. + :paramtype scope: + ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesScope + :keyword role_definition: Details of role definition. + :paramtype role_definition: + ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesRoleDefinition + :keyword policy: Details of the policy. + :paramtype policy: + ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentPropertiesPolicy + """ super(PolicyAssignmentProperties, self).__init__(**kwargs) self.scope = scope self.role_definition = role_definition @@ -499,12 +621,12 @@ class PolicyAssignmentPropertiesPolicy(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Id of the policy. - :type id: str + :ivar id: Id of the policy. + :vartype id: str :ivar last_modified_by: The name of the entity last modified it. :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal - :param last_modified_date_time: The last modified date time. - :type last_modified_date_time: ~datetime.datetime + :ivar last_modified_date_time: The last modified date time. + :vartype last_modified_date_time: ~datetime.datetime """ _validation = { @@ -524,6 +646,12 @@ def __init__( last_modified_date_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword id: Id of the policy. + :paramtype id: str + :keyword last_modified_date_time: The last modified date time. + :paramtype last_modified_date_time: ~datetime.datetime + """ super(PolicyAssignmentPropertiesPolicy, self).__init__(**kwargs) self.id = id self.last_modified_by = None @@ -533,12 +661,12 @@ def __init__( class PolicyAssignmentPropertiesRoleDefinition(msrest.serialization.Model): """Details of role definition. - :param id: Id of the role definition. - :type id: str - :param display_name: Display name of the role definition. - :type display_name: str - :param type: Type of the role definition. - :type type: str + :ivar id: Id of the role definition. + :vartype id: str + :ivar display_name: Display name of the role definition. + :vartype display_name: str + :ivar type: Type of the role definition. + :vartype type: str """ _attribute_map = { @@ -555,6 +683,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: Id of the role definition. + :paramtype id: str + :keyword display_name: Display name of the role definition. + :paramtype display_name: str + :keyword type: Type of the role definition. + :paramtype type: str + """ super(PolicyAssignmentPropertiesRoleDefinition, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -564,12 +700,12 @@ def __init__( class PolicyAssignmentPropertiesScope(msrest.serialization.Model): """Details of the resource scope. - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str """ _attribute_map = { @@ -586,6 +722,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ super(PolicyAssignmentPropertiesScope, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -613,6 +757,8 @@ def __init__( self, **kwargs ): + """ + """ super(PolicyProperties, self).__init__(**kwargs) self.scope = None @@ -620,12 +766,12 @@ def __init__( class PolicyPropertiesScope(msrest.serialization.Model): """Details of the resource scope. - :param id: Scope id of the resource. - :type id: str - :param display_name: Display name of the resource. - :type display_name: str - :param type: Type of the resource. - :type type: str + :ivar id: Scope id of the resource. + :vartype id: str + :ivar display_name: Display name of the resource. + :vartype display_name: str + :ivar type: Type of the resource. + :vartype type: str """ _attribute_map = { @@ -642,6 +788,14 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: Scope id of the resource. + :paramtype id: str + :keyword display_name: Display name of the resource. + :paramtype display_name: str + :keyword type: Type of the resource. + :paramtype type: str + """ super(PolicyPropertiesScope, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -651,14 +805,14 @@ def __init__( class Principal(msrest.serialization.Model): """The name of the entity last modified it. - :param id: The id of the principal made changes. - :type id: str - :param display_name: The name of the principal made changes. - :type display_name: str - :param type: Type of principal such as user , group etc. - :type type: str - :param email: Email of principal. - :type email: str + :ivar id: The id of the principal made changes. + :vartype id: str + :ivar display_name: The name of the principal made changes. + :vartype display_name: str + :ivar type: Type of principal such as user , group etc. + :vartype type: str + :ivar email: Email of principal. + :vartype email: str """ _attribute_map = { @@ -677,6 +831,16 @@ def __init__( email: Optional[str] = None, **kwargs ): + """ + :keyword id: The id of the principal made changes. + :paramtype id: str + :keyword display_name: The name of the principal made changes. + :paramtype display_name: str + :keyword type: Type of principal such as user , group etc. + :paramtype type: str + :keyword email: Email of principal. + :paramtype email: str + """ super(Principal, self).__init__(**kwargs) self.id = id self.display_name = display_name @@ -697,22 +861,23 @@ class RoleAssignment(msrest.serialization.Model): :vartype type: str :ivar scope: The role assignment scope. :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :ivar description: Description of role assignment. + :vartype description: str + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. @@ -721,8 +886,8 @@ class RoleAssignment(msrest.serialization.Model): :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str """ _validation = { @@ -766,6 +931,27 @@ def __init__( delegated_managed_identity_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :keyword description: Description of role assignment. + :paramtype description: str + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :paramtype delegated_managed_identity_resource_id: str + """ super(RoleAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -793,22 +979,23 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): :ivar scope: The role assignment scope. :vartype scope: str - :param role_definition_id: Required. The role definition ID. - :type role_definition_id: str - :param principal_id: Required. The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param description: Description of role assignment. - :type description: str - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar role_definition_id: Required. The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: Required. The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :ivar description: Description of role assignment. + :vartype description: str + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str :ivar created_on: Time it was created. :vartype created_on: ~datetime.datetime :ivar updated_on: Time it was updated. @@ -817,8 +1004,8 @@ class RoleAssignmentCreateParameters(msrest.serialization.Model): :vartype created_by: str :ivar updated_by: Id of the user who updated the assignment. :vartype updated_by: str - :param delegated_managed_identity_resource_id: Id of the delegated managed identity resource. - :type delegated_managed_identity_resource_id: str + :ivar delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :vartype delegated_managed_identity_resource_id: str """ _validation = { @@ -858,6 +1045,27 @@ def __init__( delegated_managed_identity_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: Required. The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: Required. The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :keyword description: Description of role assignment. + :paramtype description: str + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword delegated_managed_identity_resource_id: Id of the delegated managed identity resource. + :paramtype delegated_managed_identity_resource_id: str + """ super(RoleAssignmentCreateParameters, self).__init__(**kwargs) self.scope = None self.role_definition_id = role_definition_id @@ -876,8 +1084,8 @@ def __init__( class RoleAssignmentFilter(msrest.serialization.Model): """Role Assignments filter. - :param principal_id: Returns role assignment of the specific principal. - :type principal_id: str + :ivar principal_id: Returns role assignment of the specific principal. + :vartype principal_id: str """ _attribute_map = { @@ -890,6 +1098,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment of the specific principal. + :paramtype principal_id: str + """ super(RoleAssignmentFilter, self).__init__(**kwargs) self.principal_id = principal_id @@ -899,8 +1111,8 @@ class RoleAssignmentListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Role assignment list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] + :ivar value: Role assignment list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -920,6 +1132,10 @@ def __init__( value: Optional[List["RoleAssignment"]] = None, **kwargs ): + """ + :keyword value: Role assignment list. + :paramtype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment] + """ super(RoleAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -936,52 +1152,53 @@ class RoleAssignmentSchedule(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment schedule type. :vartype type: str - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + :ivar scope: The role assignment schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :ivar role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to create this roleAssignmentSchedule. - :type role_assignment_schedule_request_id: str - :param linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated + :vartype role_assignment_schedule_request_id: str + :ivar linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to activated this roleAssignmentSchedule. - :type linked_role_eligibility_schedule_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values + :vartype linked_role_eligibility_schedule_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Possible values include: "Activated", "Assigned". - :type assignment_type: str or + :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: + :ivar member_type: Membership type of the role assignment schedule. Possible values include: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role assignment schedule. Possible values include: "Accepted", + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :ivar status: The status of the role assignment schedule. Possible values include: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role assignment schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role assignment schedule. - :type end_date_time: ~datetime.datetime - :param condition: The conditions on the role assignment. This limits the resources it can be + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :ivar start_date_time: Start DateTime when role assignment schedule. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: End DateTime when role assignment schedule. + :vartype end_date_time: ~datetime.datetime + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role assignment schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: DateTime when role assignment schedule was modified. + :vartype updated_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ @@ -1034,6 +1251,56 @@ def __init__( expanded_properties: Optional["ExpandedProperties"] = None, **kwargs ): + """ + :keyword scope: The role assignment schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :keyword role_assignment_schedule_request_id: The id of roleAssignmentScheduleRequest used to + create this roleAssignmentSchedule. + :paramtype role_assignment_schedule_request_id: str + :keyword linked_role_eligibility_schedule_id: The id of roleEligibilitySchedule used to + activated this roleAssignmentSchedule. + :paramtype linked_role_eligibility_schedule_id: str + :keyword assignment_type: Assignment type of the role assignment schedule. Possible values + include: "Activated", "Assigned". + :paramtype assignment_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType + :keyword member_type: Membership type of the role assignment schedule. Possible values include: + "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :keyword status: The status of the role assignment schedule. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :keyword start_date_time: Start DateTime when role assignment schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: End DateTime when role assignment schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role assignment schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: DateTime when role assignment schedule was modified. + :paramtype updated_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties + """ super(RoleAssignmentSchedule, self).__init__(**kwargs) self.id = None self.name = None @@ -1059,12 +1326,12 @@ def __init__( class RoleAssignmentScheduleFilter(msrest.serialization.Model): """Role assignment schedule filter. - :param principal_id: Returns role assignment schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str + :ivar principal_id: Returns role assignment schedule of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment schedule of the specific role definition. + :vartype role_definition_id: str + :ivar status: Returns role assignment schedule instances of the specific status. + :vartype status: str """ _attribute_map = { @@ -1081,6 +1348,14 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment schedule of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment schedule of the specific role definition. + :paramtype role_definition_id: str + :keyword status: Returns role assignment schedule instances of the specific status. + :paramtype status: str + """ super(RoleAssignmentScheduleFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1098,53 +1373,54 @@ class RoleAssignmentScheduleInstance(msrest.serialization.Model): :vartype name: str :ivar type: The role assignment schedule instance type. :vartype type: str - :param scope: The role assignment schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_assignment_schedule_id: Id of the master role assignment schedule. - :type role_assignment_schedule_id: str - :param origin_role_assignment_id: Role Assignment Id in external system. - :type origin_role_assignment_id: str - :param status: The status of the role assignment schedule instance. Possible values include: + :ivar scope: The role assignment schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :ivar role_assignment_schedule_id: Id of the master role assignment schedule. + :vartype role_assignment_schedule_id: str + :ivar origin_role_assignment_id: Role Assignment Id in external system. + :vartype origin_role_assignment_id: str + :ivar status: The status of the role assignment schedule instance. Possible values include: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role assignment schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role assignment schedule instance. - :type end_date_time: ~datetime.datetime - :param linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. - :type linked_role_eligibility_schedule_id: str - :param linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked - to this roleAssignmentScheduleInstance. - :type linked_role_eligibility_schedule_instance_id: str - :param assignment_type: Assignment type of the role assignment schedule. Possible values + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :ivar start_date_time: The startDateTime of the role assignment schedule instance. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The endDateTime of the role assignment schedule instance. + :vartype end_date_time: ~datetime.datetime + :ivar linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. + :vartype linked_role_eligibility_schedule_id: str + :ivar linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked to + this roleAssignmentScheduleInstance. + :vartype linked_role_eligibility_schedule_instance_id: str + :ivar assignment_type: Assignment type of the role assignment schedule. Possible values include: "Activated", "Assigned". - :type assignment_type: str or + :vartype assignment_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType - :param member_type: Membership type of the role assignment schedule. Possible values include: + :ivar member_type: Membership type of the role assignment schedule. Possible values include: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param condition: The conditions on the role assignment. This limits the resources it can be + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role assignment schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role assignment schedule was created. + :vartype created_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ @@ -1199,6 +1475,57 @@ def __init__( expanded_properties: Optional["ExpandedProperties"] = None, **kwargs ): + """ + :keyword scope: The role assignment schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :keyword role_assignment_schedule_id: Id of the master role assignment schedule. + :paramtype role_assignment_schedule_id: str + :keyword origin_role_assignment_id: Role Assignment Id in external system. + :paramtype origin_role_assignment_id: str + :keyword status: The status of the role assignment schedule instance. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :keyword start_date_time: The startDateTime of the role assignment schedule instance. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The endDateTime of the role assignment schedule instance. + :paramtype end_date_time: ~datetime.datetime + :keyword linked_role_eligibility_schedule_id: roleEligibilityScheduleId used to activate. + :paramtype linked_role_eligibility_schedule_id: str + :keyword linked_role_eligibility_schedule_instance_id: roleEligibilityScheduleInstanceId linked + to this roleAssignmentScheduleInstance. + :paramtype linked_role_eligibility_schedule_instance_id: str + :keyword assignment_type: Assignment type of the role assignment schedule. Possible values + include: "Activated", "Assigned". + :paramtype assignment_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.AssignmentType + :keyword member_type: Membership type of the role assignment schedule. Possible values include: + "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role assignment schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties + """ super(RoleAssignmentScheduleInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -1225,16 +1552,16 @@ def __init__( class RoleAssignmentScheduleInstanceFilter(msrest.serialization.Model): """Role assignment schedule instance filter. - :param principal_id: Returns role assignment schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment schedule instances of the specific role + :ivar principal_id: Returns role assignment schedule instances of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment schedule instances of the specific role definition. - :type role_definition_id: str - :param status: Returns role assignment schedule instances of the specific status. - :type status: str - :param role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + :vartype role_definition_id: str + :ivar status: Returns role assignment schedule instances of the specific status. + :vartype status: str + :ivar role_assignment_schedule_id: Returns role assignment schedule instances belonging to a specific role assignment schedule. - :type role_assignment_schedule_id: str + :vartype role_assignment_schedule_id: str """ _attribute_map = { @@ -1253,6 +1580,18 @@ def __init__( role_assignment_schedule_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment schedule instances of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment schedule instances of the specific role + definition. + :paramtype role_definition_id: str + :keyword status: Returns role assignment schedule instances of the specific status. + :paramtype status: str + :keyword role_assignment_schedule_id: Returns role assignment schedule instances belonging to a + specific role assignment schedule. + :paramtype role_assignment_schedule_id: str + """ super(RoleAssignmentScheduleInstanceFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1263,11 +1602,11 @@ def __init__( class RoleAssignmentScheduleInstanceListResult(msrest.serialization.Model): """Role assignment schedule instance list operation result. - :param value: Role assignment schedule instance list. - :type value: + :ivar value: Role assignment schedule instance list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1282,6 +1621,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment schedule instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentScheduleInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1290,10 +1636,11 @@ def __init__( class RoleAssignmentScheduleListResult(msrest.serialization.Model): """Role assignment schedule list operation result. - :param value: Role assignment schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role assignment schedule list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1308,6 +1655,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment schedule list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentSchedule] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentScheduleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1326,18 +1680,18 @@ class RoleAssignmentScheduleRequest(msrest.serialization.Model): :vartype type: str :ivar scope: The role assignment schedule request scope. :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Possible values include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, + :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType + :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :ivar status: The status of the role assignment schedule request. Possible values include: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", @@ -1347,30 +1701,30 @@ class RoleAssignmentScheduleRequest(msrest.serialization.Model): :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar approval_id: The approvalId of the role assignment schedule request. :vartype approval_id: str - :param target_role_assignment_schedule_id: The resultant role assignment schedule id or the - role assignment schedule id being updated. - :type target_role_assignment_schedule_id: str - :param target_role_assignment_schedule_instance_id: The role assignment schedule instance id + :ivar target_role_assignment_schedule_id: The resultant role assignment schedule id or the role + assignment schedule id being updated. + :vartype target_role_assignment_schedule_id: str + :ivar target_role_assignment_schedule_instance_id: The role assignment schedule instance id being updated. - :type target_role_assignment_schedule_instance_id: str - :param schedule_info: Schedule info of the role assignment schedule. - :type schedule_info: + :vartype target_role_assignment_schedule_instance_id: str + :ivar schedule_info: Schedule info of the role assignment schedule. + :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo - :param linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + :ivar linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to activate an eligibility. - :type linked_role_eligibility_schedule_id: str - :param justification: Justification for the role assignment. - :type justification: str - :param ticket_info: Ticket Info of the role assignment. - :type ticket_info: + :vartype linked_role_eligibility_schedule_id: str + :ivar justification: Justification for the role assignment. + :vartype justification: str + :ivar ticket_info: Ticket Info of the role assignment. + :vartype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str :ivar created_on: DateTime when role assignment schedule request was created. :vartype created_on: ~datetime.datetime :ivar requestor_id: Id of the user who created this request. @@ -1433,6 +1787,41 @@ def __init__( condition_version: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", + "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". + :paramtype request_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType + :keyword target_role_assignment_schedule_id: The resultant role assignment schedule id or the + role assignment schedule id being updated. + :paramtype target_role_assignment_schedule_id: str + :keyword target_role_assignment_schedule_instance_id: The role assignment schedule instance id + being updated. + :paramtype target_role_assignment_schedule_instance_id: str + :keyword schedule_info: Schedule info of the role assignment schedule. + :paramtype schedule_info: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfo + :keyword linked_role_eligibility_schedule_id: The linked role eligibility schedule id - to + activate an eligibility. + :paramtype linked_role_eligibility_schedule_id: str + :keyword justification: Justification for the role assignment. + :paramtype justification: str + :keyword ticket_info: Ticket Info of the role assignment. + :paramtype ticket_info: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesTicketInfo + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + """ super(RoleAssignmentScheduleRequest, self).__init__(**kwargs) self.id = None self.name = None @@ -1460,14 +1849,14 @@ def __init__( class RoleAssignmentScheduleRequestFilter(msrest.serialization.Model): """Role assignment schedule request filter. - :param principal_id: Returns role assignment requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role assignment requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role assignment requests created by specific principal. - :type requestor_id: str - :param status: Returns role assignment requests of specific status. - :type status: str + :ivar principal_id: Returns role assignment requests of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role assignment requests of the specific role definition. + :vartype role_definition_id: str + :ivar requestor_id: Returns role assignment requests created by specific principal. + :vartype requestor_id: str + :ivar status: Returns role assignment requests of specific status. + :vartype status: str """ _attribute_map = { @@ -1486,6 +1875,16 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role assignment requests of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role assignment requests of the specific role definition. + :paramtype role_definition_id: str + :keyword requestor_id: Returns role assignment requests created by specific principal. + :paramtype requestor_id: str + :keyword status: Returns role assignment requests of specific status. + :paramtype status: str + """ super(RoleAssignmentScheduleRequestFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1496,11 +1895,11 @@ def __init__( class RoleAssignmentScheduleRequestListResult(msrest.serialization.Model): """Role assignment schedule request list operation result. - :param value: Role assignment schedule request list. - :type value: + :ivar value: Role assignment schedule request list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1515,6 +1914,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role assignment schedule request list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleAssignmentScheduleRequestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1523,10 +1929,10 @@ def __init__( class RoleAssignmentScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): """Schedule info of the role assignment schedule. - :param start_date_time: Start DateTime of the role assignment schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role assignment schedule. - :type expiration: + :ivar start_date_time: Start DateTime of the role assignment schedule. + :vartype start_date_time: ~datetime.datetime + :ivar expiration: Expiration of the role assignment schedule. + :vartype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration """ @@ -1542,6 +1948,13 @@ def __init__( expiration: Optional["RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs ): + """ + :keyword start_date_time: Start DateTime of the role assignment schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword expiration: Expiration of the role assignment schedule. + :paramtype expiration: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration + """ super(RoleAssignmentScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration @@ -1550,13 +1963,13 @@ def __init__( class RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): """Expiration of the role assignment schedule. - :param type: Type of the role assignment schedule expiration. Possible values include: + :ivar type: Type of the role assignment schedule expiration. Possible values include: "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role assignment schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role assignment schedule in TimeSpan. - :type duration: str + :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type + :ivar end_date_time: End DateTime of the role assignment schedule. + :vartype end_date_time: ~datetime.datetime + :ivar duration: Duration of the role assignment schedule in TimeSpan. + :vartype duration: str """ _attribute_map = { @@ -1573,6 +1986,15 @@ def __init__( duration: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of the role assignment schedule expiration. Possible values include: + "AfterDuration", "AfterDateTime", "NoExpiration". + :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type + :keyword end_date_time: End DateTime of the role assignment schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword duration: Duration of the role assignment schedule in TimeSpan. + :paramtype duration: str + """ super(RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) self.type = type self.end_date_time = end_date_time @@ -1582,10 +2004,10 @@ def __init__( class RoleAssignmentScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): """Ticket Info of the role assignment. - :param ticket_number: Ticket number for the role assignment. - :type ticket_number: str - :param ticket_system: Ticket system name for the role assignment. - :type ticket_system: str + :ivar ticket_number: Ticket number for the role assignment. + :vartype ticket_number: str + :ivar ticket_system: Ticket system name for the role assignment. + :vartype ticket_system: str """ _attribute_map = { @@ -1600,6 +2022,12 @@ def __init__( ticket_system: Optional[str] = None, **kwargs ): + """ + :keyword ticket_number: Ticket number for the role assignment. + :paramtype ticket_number: str + :keyword ticket_system: Ticket system name for the role assignment. + :paramtype ticket_system: str + """ super(RoleAssignmentScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system @@ -1616,45 +2044,46 @@ class RoleEligibilitySchedule(msrest.serialization.Model): :vartype name: str :ivar type: The role eligibility schedule type. :vartype type: str - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + :ivar scope: The role eligibility schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :ivar role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to create this roleAssignmentSchedule. - :type role_eligibility_schedule_request_id: str - :param member_type: Membership type of the role eligibility schedule. Possible values include: + :vartype role_eligibility_schedule_request_id: str + :ivar member_type: Membership type of the role eligibility schedule. Possible values include: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param status: The status of the role eligibility schedule. Possible values include: - "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :ivar status: The status of the role eligibility schedule. Possible values include: "Accepted", + "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: Start DateTime when role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param end_date_time: End DateTime when role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param condition: The conditions on the role assignment. This limits the resources it can be + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :ivar start_date_time: Start DateTime when role eligibility schedule. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: End DateTime when role eligibility schedule. + :vartype end_date_time: ~datetime.datetime + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param updated_on: DateTime when role eligibility schedule was modified. - :type updated_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule was created. + :vartype created_on: ~datetime.datetime + :ivar updated_on: DateTime when role eligibility schedule was modified. + :vartype updated_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ @@ -1703,6 +2132,49 @@ def __init__( expanded_properties: Optional["ExpandedProperties"] = None, **kwargs ): + """ + :keyword scope: The role eligibility schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :keyword role_eligibility_schedule_request_id: The id of roleEligibilityScheduleRequest used to + create this roleAssignmentSchedule. + :paramtype role_eligibility_schedule_request_id: str + :keyword member_type: Membership type of the role eligibility schedule. Possible values + include: "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :keyword status: The status of the role eligibility schedule. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :keyword start_date_time: Start DateTime when role eligibility schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: End DateTime when role eligibility schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role eligibility schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword updated_on: DateTime when role eligibility schedule was modified. + :paramtype updated_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties + """ super(RoleEligibilitySchedule, self).__init__(**kwargs) self.id = None self.name = None @@ -1726,12 +2198,12 @@ def __init__( class RoleEligibilityScheduleFilter(msrest.serialization.Model): """Role eligibility schedule filter. - :param principal_id: Returns role eligibility schedule of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule of the specific role definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule of the specific status. - :type status: str + :ivar principal_id: Returns role eligibility schedule of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility schedule of the specific role definition. + :vartype role_definition_id: str + :ivar status: Returns role eligibility schedule of the specific status. + :vartype status: str """ _attribute_map = { @@ -1748,6 +2220,14 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role eligibility schedule of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility schedule of the specific role definition. + :paramtype role_definition_id: str + :keyword status: Returns role eligibility schedule of the specific status. + :paramtype status: str + """ super(RoleEligibilityScheduleFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1765,42 +2245,43 @@ class RoleEligibilityScheduleInstance(msrest.serialization.Model): :vartype name: str :ivar type: The role eligibility schedule instance type. :vartype type: str - :param scope: The role eligibility schedule scope. - :type scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str - :param principal_type: The principal type of the assigned principal ID. Possible values - include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". - :type principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param role_eligibility_schedule_id: Id of the master role eligibility schedule. - :type role_eligibility_schedule_id: str - :param status: The status of the role eligibility schedule instance. Possible values include: + :ivar scope: The role eligibility schedule scope. + :vartype scope: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str + :ivar principal_type: The principal type of the assigned principal ID. Possible values include: + "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :ivar role_eligibility_schedule_id: Id of the master role eligibility schedule. + :vartype role_eligibility_schedule_id: str + :ivar status: The status of the role eligibility schedule instance. Possible values include: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", "ScheduleCreated", "PendingExternalProvisioning". - :type status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status - :param start_date_time: The startDateTime of the role eligibility schedule instance. - :type start_date_time: ~datetime.datetime - :param end_date_time: The endDateTime of the role eligibility schedule instance. - :type end_date_time: ~datetime.datetime - :param member_type: Membership type of the role eligibility schedule. Possible values include: + :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :ivar start_date_time: The startDateTime of the role eligibility schedule instance. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The endDateTime of the role eligibility schedule instance. + :vartype end_date_time: ~datetime.datetime + :ivar member_type: Membership type of the role eligibility schedule. Possible values include: "Inherited", "Direct", "Group". - :type member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType - :param condition: The conditions on the role assignment. This limits the resources it can be + :vartype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str - :param created_on: DateTime when role eligibility schedule was created. - :type created_on: ~datetime.datetime - :param expanded_properties: Additional properties of principal, scope and role definition. - :type expanded_properties: + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str + :ivar created_on: DateTime when role eligibility schedule was created. + :vartype created_on: ~datetime.datetime + :ivar expanded_properties: Additional properties of principal, scope and role definition. + :vartype expanded_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties """ @@ -1847,6 +2328,46 @@ def __init__( expanded_properties: Optional["ExpandedProperties"] = None, **kwargs ): + """ + :keyword scope: The role eligibility schedule scope. + :paramtype scope: str + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword principal_type: The principal type of the assigned principal ID. Possible values + include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". + :paramtype principal_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType + :keyword role_eligibility_schedule_id: Id of the master role eligibility schedule. + :paramtype role_eligibility_schedule_id: str + :keyword status: The status of the role eligibility schedule instance. Possible values include: + "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", + "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", + "PendingApproval", "FailedAsResourceIsLocked", "PendingAdminDecision", "AdminApproved", + "AdminDenied", "TimedOut", "ProvisioningStarted", "Invalid", "PendingScheduleCreation", + "ScheduleCreated", "PendingExternalProvisioning". + :paramtype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status + :keyword start_date_time: The startDateTime of the role eligibility schedule instance. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The endDateTime of the role eligibility schedule instance. + :paramtype end_date_time: ~datetime.datetime + :keyword member_type: Membership type of the role eligibility schedule. Possible values + include: "Inherited", "Direct", "Group". + :paramtype member_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.MemberType + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + :keyword created_on: DateTime when role eligibility schedule was created. + :paramtype created_on: ~datetime.datetime + :keyword expanded_properties: Additional properties of principal, scope and role definition. + :paramtype expanded_properties: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ExpandedProperties + """ super(RoleEligibilityScheduleInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -1869,16 +2390,16 @@ def __init__( class RoleEligibilityScheduleInstanceFilter(msrest.serialization.Model): """Role eligibility schedule instance filter. - :param principal_id: Returns role eligibility schedule instances of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility schedule instances of the specific role + :ivar principal_id: Returns role eligibility schedule instances of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility schedule instances of the specific role definition. - :type role_definition_id: str - :param status: Returns role eligibility schedule instances of the specific status. - :type status: str - :param role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a + :vartype role_definition_id: str + :ivar status: Returns role eligibility schedule instances of the specific status. + :vartype status: str + :ivar role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to a specific role eligibility schedule. - :type role_eligibility_schedule_id: str + :vartype role_eligibility_schedule_id: str """ _attribute_map = { @@ -1897,6 +2418,18 @@ def __init__( role_eligibility_schedule_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role eligibility schedule instances of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility schedule instances of the specific role + definition. + :paramtype role_definition_id: str + :keyword status: Returns role eligibility schedule instances of the specific status. + :paramtype status: str + :keyword role_eligibility_schedule_id: Returns role eligibility schedule instances belonging to + a specific role eligibility schedule. + :paramtype role_eligibility_schedule_id: str + """ super(RoleEligibilityScheduleInstanceFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -1907,11 +2440,11 @@ def __init__( class RoleEligibilityScheduleInstanceListResult(msrest.serialization.Model): """Role eligibility schedule instance list operation result. - :param value: Role eligibility schedule instance list. - :type value: + :ivar value: Role eligibility schedule instance list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1926,6 +2459,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role eligibility schedule instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleEligibilityScheduleInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1934,10 +2474,11 @@ def __init__( class RoleEligibilityScheduleListResult(msrest.serialization.Model): """role eligibility schedule list operation result. - :param value: role eligibility schedule list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: role eligibility schedule list. + :vartype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -1952,6 +2493,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: role eligibility schedule list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilitySchedule] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleEligibilityScheduleListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1970,18 +2518,18 @@ class RoleEligibilityScheduleRequest(msrest.serialization.Model): :vartype type: str :ivar scope: The role eligibility schedule request scope. :vartype scope: str - :param role_definition_id: The role definition ID. - :type role_definition_id: str - :param principal_id: The principal ID. - :type principal_id: str + :ivar role_definition_id: The role definition ID. + :vartype role_definition_id: str + :ivar principal_id: The principal ID. + :vartype principal_id: str :ivar principal_type: The principal type of the assigned principal ID. Possible values include: "User", "Group", "ServicePrincipal", "ForeignGroup", "Device". :vartype principal_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.PrincipalType - :param request_type: The type of the role assignment schedule request. Eg: SelfActivate, + :ivar request_type: The type of the role assignment schedule request. Eg: SelfActivate, AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". - :type request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType + :vartype request_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType :ivar status: The status of the role eligibility schedule request. Possible values include: "Accepted", "PendingEvaluation", "Granted", "Denied", "PendingProvisioning", "Provisioned", "PendingRevocation", "Revoked", "Canceled", "Failed", "PendingApprovalProvisioning", @@ -1991,27 +2539,27 @@ class RoleEligibilityScheduleRequest(msrest.serialization.Model): :vartype status: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Status :ivar approval_id: The approvalId of the role eligibility schedule request. :vartype approval_id: str - :param schedule_info: Schedule info of the role eligibility schedule. - :type schedule_info: + :ivar schedule_info: Schedule info of the role eligibility schedule. + :vartype schedule_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo - :param target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + :ivar target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the role eligibility schedule id being updated. - :type target_role_eligibility_schedule_id: str - :param target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id + :vartype target_role_eligibility_schedule_id: str + :ivar target_role_eligibility_schedule_instance_id: The role eligibility schedule instance id being updated. - :type target_role_eligibility_schedule_instance_id: str - :param justification: Justification for the role eligibility. - :type justification: str - :param ticket_info: Ticket Info of the role eligibility. - :type ticket_info: + :vartype target_role_eligibility_schedule_instance_id: str + :ivar justification: Justification for the role eligibility. + :vartype justification: str + :ivar ticket_info: Ticket Info of the role eligibility. + :vartype ticket_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo - :param condition: The conditions on the role assignment. This limits the resources it can be + :ivar condition: The conditions on the role assignment. This limits the resources it can be assigned to. e.g.: @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'. - :type condition: str - :param condition_version: Version of the condition. Currently accepted value is '2.0'. - :type condition_version: str + :vartype condition: str + :ivar condition_version: Version of the condition. Currently accepted value is '2.0'. + :vartype condition_version: str :ivar created_on: DateTime when role eligibility schedule request was created. :vartype created_on: ~datetime.datetime :ivar requestor_id: Id of the user who created this request. @@ -2072,6 +2620,38 @@ def __init__( condition_version: Optional[str] = None, **kwargs ): + """ + :keyword role_definition_id: The role definition ID. + :paramtype role_definition_id: str + :keyword principal_id: The principal ID. + :paramtype principal_id: str + :keyword request_type: The type of the role assignment schedule request. Eg: SelfActivate, + AdminAssign etc. Possible values include: "AdminAssign", "AdminRemove", "AdminUpdate", + "AdminExtend", "AdminRenew", "SelfActivate", "SelfDeactivate", "SelfExtend", "SelfRenew". + :paramtype request_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.RequestType + :keyword schedule_info: Schedule info of the role eligibility schedule. + :paramtype schedule_info: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfo + :keyword target_role_eligibility_schedule_id: The resultant role eligibility schedule id or the + role eligibility schedule id being updated. + :paramtype target_role_eligibility_schedule_id: str + :keyword target_role_eligibility_schedule_instance_id: The role eligibility schedule instance + id being updated. + :paramtype target_role_eligibility_schedule_instance_id: str + :keyword justification: Justification for the role eligibility. + :paramtype justification: str + :keyword ticket_info: Ticket Info of the role eligibility. + :paramtype ticket_info: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesTicketInfo + :keyword condition: The conditions on the role assignment. This limits the resources it can be + assigned to. e.g.: + @Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] + StringEqualsIgnoreCase 'foo_storage_container'. + :paramtype condition: str + :keyword condition_version: Version of the condition. Currently accepted value is '2.0'. + :paramtype condition_version: str + """ super(RoleEligibilityScheduleRequest, self).__init__(**kwargs) self.id = None self.name = None @@ -2098,14 +2678,14 @@ def __init__( class RoleEligibilityScheduleRequestFilter(msrest.serialization.Model): """Role eligibility schedule request filter. - :param principal_id: Returns role eligibility requests of the specific principal. - :type principal_id: str - :param role_definition_id: Returns role eligibility requests of the specific role definition. - :type role_definition_id: str - :param requestor_id: Returns role eligibility requests created by specific principal. - :type requestor_id: str - :param status: Returns role eligibility requests of specific status. - :type status: str + :ivar principal_id: Returns role eligibility requests of the specific principal. + :vartype principal_id: str + :ivar role_definition_id: Returns role eligibility requests of the specific role definition. + :vartype role_definition_id: str + :ivar requestor_id: Returns role eligibility requests created by specific principal. + :vartype requestor_id: str + :ivar status: Returns role eligibility requests of specific status. + :vartype status: str """ _attribute_map = { @@ -2124,6 +2704,16 @@ def __init__( status: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: Returns role eligibility requests of the specific principal. + :paramtype principal_id: str + :keyword role_definition_id: Returns role eligibility requests of the specific role definition. + :paramtype role_definition_id: str + :keyword requestor_id: Returns role eligibility requests created by specific principal. + :paramtype requestor_id: str + :keyword status: Returns role eligibility requests of specific status. + :paramtype status: str + """ super(RoleEligibilityScheduleRequestFilter, self).__init__(**kwargs) self.principal_id = principal_id self.role_definition_id = role_definition_id @@ -2134,11 +2724,11 @@ def __init__( class RoleEligibilityScheduleRequestListResult(msrest.serialization.Model): """Role eligibility schedule request list operation result. - :param value: Role eligibility schedule request list. - :type value: + :ivar value: Role eligibility schedule request list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2153,6 +2743,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role eligibility schedule request list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleEligibilityScheduleRequestListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2161,10 +2758,10 @@ def __init__( class RoleEligibilityScheduleRequestPropertiesScheduleInfo(msrest.serialization.Model): """Schedule info of the role eligibility schedule. - :param start_date_time: Start DateTime of the role eligibility schedule. - :type start_date_time: ~datetime.datetime - :param expiration: Expiration of the role eligibility schedule. - :type expiration: + :ivar start_date_time: Start DateTime of the role eligibility schedule. + :vartype start_date_time: ~datetime.datetime + :ivar expiration: Expiration of the role eligibility schedule. + :vartype expiration: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration """ @@ -2180,6 +2777,13 @@ def __init__( expiration: Optional["RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration"] = None, **kwargs ): + """ + :keyword start_date_time: Start DateTime of the role eligibility schedule. + :paramtype start_date_time: ~datetime.datetime + :keyword expiration: Expiration of the role eligibility schedule. + :paramtype expiration: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration + """ super(RoleEligibilityScheduleRequestPropertiesScheduleInfo, self).__init__(**kwargs) self.start_date_time = start_date_time self.expiration = expiration @@ -2188,13 +2792,13 @@ def __init__( class RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration(msrest.serialization.Model): """Expiration of the role eligibility schedule. - :param type: Type of the role eligibility schedule expiration. Possible values include: + :ivar type: Type of the role eligibility schedule expiration. Possible values include: "AfterDuration", "AfterDateTime", "NoExpiration". - :type type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type - :param end_date_time: End DateTime of the role eligibility schedule. - :type end_date_time: ~datetime.datetime - :param duration: Duration of the role eligibility schedule in TimeSpan. - :type duration: str + :vartype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type + :ivar end_date_time: End DateTime of the role eligibility schedule. + :vartype end_date_time: ~datetime.datetime + :ivar duration: Duration of the role eligibility schedule in TimeSpan. + :vartype duration: str """ _attribute_map = { @@ -2211,6 +2815,15 @@ def __init__( duration: Optional[str] = None, **kwargs ): + """ + :keyword type: Type of the role eligibility schedule expiration. Possible values include: + "AfterDuration", "AfterDateTime", "NoExpiration". + :paramtype type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.Type + :keyword end_date_time: End DateTime of the role eligibility schedule. + :paramtype end_date_time: ~datetime.datetime + :keyword duration: Duration of the role eligibility schedule in TimeSpan. + :paramtype duration: str + """ super(RoleEligibilityScheduleRequestPropertiesScheduleInfoExpiration, self).__init__(**kwargs) self.type = type self.end_date_time = end_date_time @@ -2220,10 +2833,10 @@ def __init__( class RoleEligibilityScheduleRequestPropertiesTicketInfo(msrest.serialization.Model): """Ticket Info of the role eligibility. - :param ticket_number: Ticket number for the role eligibility. - :type ticket_number: str - :param ticket_system: Ticket system name for the role eligibility. - :type ticket_system: str + :ivar ticket_number: Ticket number for the role eligibility. + :vartype ticket_number: str + :ivar ticket_system: Ticket system name for the role eligibility. + :vartype ticket_system: str """ _attribute_map = { @@ -2238,6 +2851,12 @@ def __init__( ticket_system: Optional[str] = None, **kwargs ): + """ + :keyword ticket_number: Ticket number for the role eligibility. + :paramtype ticket_number: str + :keyword ticket_system: Ticket system name for the role eligibility. + :paramtype ticket_system: str + """ super(RoleEligibilityScheduleRequestPropertiesTicketInfo, self).__init__(**kwargs) self.ticket_number = ticket_number self.ticket_system = ticket_system @@ -2254,20 +2873,20 @@ class RoleManagementPolicy(msrest.serialization.Model): :vartype name: str :ivar type: The role management policy type. :vartype type: str - :param scope: The role management policy scope. - :type scope: str - :param display_name: The role management policy display name. - :type display_name: str - :param description: The role management policy description. - :type description: str - :param is_organization_default: The role management policy is default policy. - :type is_organization_default: bool + :ivar scope: The role management policy scope. + :vartype scope: str + :ivar display_name: The role management policy display name. + :vartype display_name: str + :ivar description: The role management policy description. + :vartype description: str + :ivar is_organization_default: The role management policy is default policy. + :vartype is_organization_default: bool :ivar last_modified_by: The name of the entity last modified it. :vartype last_modified_by: ~azure.mgmt.authorization.v2020_10_01_preview.models.Principal :ivar last_modified_date_time: The last modified date time. :vartype last_modified_date_time: ~datetime.datetime - :param rules: The rule applied to the policy. - :type rules: + :ivar rules: The rule applied to the policy. + :vartype rules: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] :ivar effective_rules: The readonly computed rule applied to the policy. :vartype effective_rules: @@ -2312,6 +2931,19 @@ def __init__( rules: Optional[List["RoleManagementPolicyRule"]] = None, **kwargs ): + """ + :keyword scope: The role management policy scope. + :paramtype scope: str + :keyword display_name: The role management policy display name. + :paramtype display_name: str + :keyword description: The role management policy description. + :paramtype description: str + :keyword is_organization_default: The role management policy is default policy. + :paramtype is_organization_default: bool + :keyword rules: The rule applied to the policy. + :paramtype rules: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRule] + """ super(RoleManagementPolicy, self).__init__(**kwargs) self.id = None self.name = None @@ -2335,16 +2967,16 @@ class RoleManagementPolicyRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget """ @@ -2369,6 +3001,13 @@ def __init__( target: Optional["RoleManagementPolicyRuleTarget"] = None, **kwargs ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget + """ super(RoleManagementPolicyRule, self).__init__(**kwargs) self.id = id self.rule_type = None # type: Optional[str] @@ -2380,19 +3019,19 @@ class RoleManagementPolicyApprovalRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param setting: The approval setting. - :type setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings + :ivar setting: The approval setting. + :vartype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings """ _validation = { @@ -2414,6 +3053,15 @@ def __init__( setting: Optional["ApprovalSettings"] = None, **kwargs ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget + :keyword setting: The approval setting. + :paramtype setting: ~azure.mgmt.authorization.v2020_10_01_preview.models.ApprovalSettings + """ super(RoleManagementPolicyApprovalRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyApprovalRule' # type: str self.setting = setting @@ -2430,12 +3078,12 @@ class RoleManagementPolicyAssignment(msrest.serialization.Model): :vartype name: str :ivar type: The role management policy type. :vartype type: str - :param scope: The role management policy scope. - :type scope: str - :param role_definition_id: The role definition of management policy assignment. - :type role_definition_id: str - :param policy_id: The policy id role management policy assignment. - :type policy_id: str + :ivar scope: The role management policy scope. + :vartype scope: str + :ivar role_definition_id: The role definition of management policy assignment. + :vartype role_definition_id: str + :ivar policy_id: The policy id role management policy assignment. + :vartype policy_id: str :ivar policy_assignment_properties: Additional properties of scope, role definition and policy. :vartype policy_assignment_properties: ~azure.mgmt.authorization.v2020_10_01_preview.models.PolicyAssignmentProperties @@ -2466,6 +3114,14 @@ def __init__( policy_id: Optional[str] = None, **kwargs ): + """ + :keyword scope: The role management policy scope. + :paramtype scope: str + :keyword role_definition_id: The role definition of management policy assignment. + :paramtype role_definition_id: str + :keyword policy_id: The policy id role management policy assignment. + :paramtype policy_id: str + """ super(RoleManagementPolicyAssignment, self).__init__(**kwargs) self.id = None self.name = None @@ -2479,11 +3135,11 @@ def __init__( class RoleManagementPolicyAssignmentListResult(msrest.serialization.Model): """Role management policy assignment list operation result. - :param value: Role management policy assignment list. - :type value: + :ivar value: Role management policy assignment list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2498,6 +3154,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role management policy assignment list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleManagementPolicyAssignmentListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2508,21 +3171,21 @@ class RoleManagementPolicyAuthenticationContextRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_enabled: The value indicating if rule is enabled. - :type is_enabled: bool - :param claim_value: The claim value. - :type claim_value: str + :ivar is_enabled: The value indicating if rule is enabled. + :vartype is_enabled: bool + :ivar claim_value: The claim value. + :vartype claim_value: str """ _validation = { @@ -2546,6 +3209,17 @@ def __init__( claim_value: Optional[str] = None, **kwargs ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget + :keyword is_enabled: The value indicating if rule is enabled. + :paramtype is_enabled: bool + :keyword claim_value: The claim value. + :paramtype claim_value: str + """ super(RoleManagementPolicyAuthenticationContextRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyAuthenticationContextRule' # type: str self.is_enabled = is_enabled @@ -2557,19 +3231,19 @@ class RoleManagementPolicyEnablementRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param enabled_rules: The list of enabled rules. - :type enabled_rules: list[str or + :ivar enabled_rules: The list of enabled rules. + :vartype enabled_rules: list[str or ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] """ @@ -2592,6 +3266,16 @@ def __init__( enabled_rules: Optional[List[Union[str, "EnablementRules"]]] = None, **kwargs ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget + :keyword enabled_rules: The list of enabled rules. + :paramtype enabled_rules: list[str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.EnablementRules] + """ super(RoleManagementPolicyEnablementRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyEnablementRule' # type: str self.enabled_rules = enabled_rules @@ -2602,21 +3286,21 @@ class RoleManagementPolicyExpirationRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param is_expiration_required: The value indicating whether expiration is required. - :type is_expiration_required: bool - :param maximum_duration: The maximum duration of expiration in timespan. - :type maximum_duration: str + :ivar is_expiration_required: The value indicating whether expiration is required. + :vartype is_expiration_required: bool + :ivar maximum_duration: The maximum duration of expiration in timespan. + :vartype maximum_duration: str """ _validation = { @@ -2640,6 +3324,17 @@ def __init__( maximum_duration: Optional[str] = None, **kwargs ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget + :keyword is_expiration_required: The value indicating whether expiration is required. + :paramtype is_expiration_required: bool + :keyword maximum_duration: The maximum duration of expiration in timespan. + :paramtype maximum_duration: str + """ super(RoleManagementPolicyExpirationRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyExpirationRule' # type: str self.is_expiration_required = is_expiration_required @@ -2649,10 +3344,10 @@ def __init__( class RoleManagementPolicyListResult(msrest.serialization.Model): """Role management policy list operation result. - :param value: Role management policy list. - :type value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Role management policy list. + :vartype value: list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -2667,6 +3362,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Role management policy list. + :paramtype value: + list[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicy] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(RoleManagementPolicyListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -2677,32 +3379,33 @@ class RoleManagementPolicyNotificationRule(RoleManagementPolicyRule): All required parameters must be populated in order to send to Azure. - :param id: The id of the rule. - :type id: str - :param rule_type: Required. The type of rule.Constant filled by server. Possible values - include: "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", + :ivar id: The id of the rule. + :vartype id: str + :ivar rule_type: Required. The type of rule.Constant filled by server. Possible values include: + "RoleManagementPolicyApprovalRule", "RoleManagementPolicyAuthenticationContextRule", "RoleManagementPolicyEnablementRule", "RoleManagementPolicyExpirationRule", "RoleManagementPolicyNotificationRule". - :type rule_type: str or + :vartype rule_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleType - :param target: The target of the current rule. - :type target: + :ivar target: The target of the current rule. + :vartype target: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget - :param notification_type: The type of notification. Possible values include: "Email". - :type notification_type: str or + :ivar notification_type: The type of notification. Possible values include: "Email". + :vartype notification_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism - :param notification_level: The notification level. Possible values include: "None", "Critical", + :ivar notification_level: The notification level. Possible values include: "None", "Critical", "All". - :type notification_level: str or + :vartype notification_level: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel - :param recipient_type: The recipient type. Possible values include: "Requestor", "Approver", + :ivar recipient_type: The recipient type. Possible values include: "Requestor", "Approver", "Admin". - :type recipient_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType - :param notification_recipients: The list notification recipients. - :type notification_recipients: list[str] - :param is_default_recipients_enabled: Its value determine if the notification need to be sent - to the recipient type specified in policy rule. - :type is_default_recipients_enabled: bool + :vartype recipient_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType + :ivar notification_recipients: The list notification recipients. + :vartype notification_recipients: list[str] + :ivar is_default_recipients_enabled: Its value determine if the notification need to be sent to + the recipient type specified in policy rule. + :vartype is_default_recipients_enabled: bool """ _validation = { @@ -2732,6 +3435,29 @@ def __init__( is_default_recipients_enabled: Optional[bool] = None, **kwargs ): + """ + :keyword id: The id of the rule. + :paramtype id: str + :keyword target: The target of the current rule. + :paramtype target: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyRuleTarget + :keyword notification_type: The type of notification. Possible values include: "Email". + :paramtype notification_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationDeliveryMechanism + :keyword notification_level: The notification level. Possible values include: "None", + "Critical", "All". + :paramtype notification_level: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.NotificationLevel + :keyword recipient_type: The recipient type. Possible values include: "Requestor", "Approver", + "Admin". + :paramtype recipient_type: str or + ~azure.mgmt.authorization.v2020_10_01_preview.models.RecipientType + :keyword notification_recipients: The list notification recipients. + :paramtype notification_recipients: list[str] + :keyword is_default_recipients_enabled: Its value determine if the notification need to be sent + to the recipient type specified in policy rule. + :paramtype is_default_recipients_enabled: bool + """ super(RoleManagementPolicyNotificationRule, self).__init__(id=id, target=target, **kwargs) self.rule_type = 'RoleManagementPolicyNotificationRule' # type: str self.notification_type = notification_type @@ -2744,18 +3470,18 @@ def __init__( class RoleManagementPolicyRuleTarget(msrest.serialization.Model): """The role management policy rule target. - :param caller: The caller of the setting. - :type caller: str - :param operations: The type of operation. - :type operations: list[str] - :param level: The assignment level to which it is applied. - :type level: str - :param target_objects: The list of target objects. - :type target_objects: list[str] - :param inheritable_settings: The list of inheritable settings. - :type inheritable_settings: list[str] - :param enforced_settings: The list of enforced settings. - :type enforced_settings: list[str] + :ivar caller: The caller of the setting. + :vartype caller: str + :ivar operations: The type of operation. + :vartype operations: list[str] + :ivar level: The assignment level to which it is applied. + :vartype level: str + :ivar target_objects: The list of target objects. + :vartype target_objects: list[str] + :ivar inheritable_settings: The list of inheritable settings. + :vartype inheritable_settings: list[str] + :ivar enforced_settings: The list of enforced settings. + :vartype enforced_settings: list[str] """ _attribute_map = { @@ -2778,6 +3504,20 @@ def __init__( enforced_settings: Optional[List[str]] = None, **kwargs ): + """ + :keyword caller: The caller of the setting. + :paramtype caller: str + :keyword operations: The type of operation. + :paramtype operations: list[str] + :keyword level: The assignment level to which it is applied. + :paramtype level: str + :keyword target_objects: The list of target objects. + :paramtype target_objects: list[str] + :keyword inheritable_settings: The list of inheritable settings. + :paramtype inheritable_settings: list[str] + :keyword enforced_settings: The list of enforced settings. + :paramtype enforced_settings: list[str] + """ super(RoleManagementPolicyRuleTarget, self).__init__(**kwargs) self.caller = caller self.operations = operations @@ -2790,14 +3530,14 @@ def __init__( class UserSet(msrest.serialization.Model): """The detail of a user. - :param user_type: The type of user. Possible values include: "User", "Group". - :type user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType - :param is_backup: The value indicating whether the user is a backup fallback approver. - :type is_backup: bool - :param id: The object id of the user. - :type id: str - :param description: The description of the user. - :type description: str + :ivar user_type: The type of user. Possible values include: "User", "Group". + :vartype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType + :ivar is_backup: The value indicating whether the user is a backup fallback approver. + :vartype is_backup: bool + :ivar id: The object id of the user. + :vartype id: str + :ivar description: The description of the user. + :vartype description: str """ _attribute_map = { @@ -2816,6 +3556,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword user_type: The type of user. Possible values include: "User", "Group". + :paramtype user_type: str or ~azure.mgmt.authorization.v2020_10_01_preview.models.UserType + :keyword is_backup: The value indicating whether the user is a backup fallback approver. + :paramtype is_backup: bool + :keyword id: The object id of the user. + :paramtype id: str + :keyword description: The description of the user. + :paramtype description: str + """ super(UserSet, self).__init__(**kwargs) self.user_type = user_type self.is_backup = is_backup @@ -2830,8 +3580,8 @@ class ValidationResponse(msrest.serialization.Model): :ivar is_valid: Whether or not validation succeeded. :vartype is_valid: bool - :param error_info: Failed validation result details. - :type error_info: + :ivar error_info: Failed validation result details. + :vartype error_info: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo """ @@ -2850,6 +3600,11 @@ def __init__( error_info: Optional["ValidationResponseErrorInfo"] = None, **kwargs ): + """ + :keyword error_info: Failed validation result details. + :paramtype error_info: + ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponseErrorInfo + """ super(ValidationResponse, self).__init__(**kwargs) self.is_valid = None self.error_info = error_info @@ -2880,6 +3635,8 @@ def __init__( self, **kwargs ): + """ + """ super(ValidationResponseErrorInfo, self).__init__(**kwargs) self.code = None self.message = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py index 5249728dc289..02a66c732772 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_eligible_child_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,60 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/eligibleChildResources") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class EligibleChildResourcesOperations(object): """EligibleChildResourcesOperations operations. @@ -45,13 +83,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EligibleChildResourcesListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.EligibleChildResourcesListResult"]: """Get the child resources of a resource on which user has eligible access. :param scope: The scope of the role management policy. @@ -59,48 +97,49 @@ def get( :param filter: The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource - of type = 'Subscription' or 'ResourceGroup'. + of type = 'Subscription' or 'ResourceGroup'. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EligibleChildResourcesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] + :return: An iterator like instance of either EligibleChildResourcesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.EligibleChildResourcesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.EligibleChildResourcesListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EligibleChildResourcesListResult', pipeline_response) + deserialized = self._deserialize("EligibleChildResourcesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,7 +148,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -118,7 +161,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/eligibleChildResources'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/eligibleChildResources"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py index fc497e655b9e..feaa517cba12 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_schedule_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleInstanceName": _SERIALIZER.url("role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentScheduleInstancesOperations(object): """RoleAssignmentScheduleInstancesOperations operations. @@ -45,13 +117,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentScheduleInstanceListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentScheduleInstanceListResult"]: """Gets role assignment schedule instances of a role assignment schedule. :param scope: The scope of the role assignment schedule. @@ -61,48 +133,49 @@ def list_for_scope( assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current - user. + user. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] + :return: An iterator like instance of either RoleAssignmentScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,7 +184,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -120,18 +197,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - role_assignment_schedule_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentScheduleInstance" + scope: str, + role_assignment_schedule_instance_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleInstance": """Gets the specified role assignment schedule instance. :param scope: The scope of the role assignments schedules. @@ -149,27 +227,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleInstanceName': self._serialize.url("role_assignment_schedule_instance_name", role_assignment_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_schedule_instance_name=role_assignment_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -182,4 +257,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleInstances/{roleAssignmentScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py index bc66ad220fe9..8b9576abe35c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedule_requests_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + scope: str, + role_assignment_schedule_request_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_cancel_request( + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleRequestName": _SERIALIZER.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentScheduleRequestsOperations(object): """RoleAssignmentScheduleRequestsOperations operations. @@ -45,14 +194,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create( self, - scope, # type: str - role_assignment_schedule_request_name, # type: str - parameters, # type: "_models.RoleAssignmentScheduleRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentScheduleRequest" + scope: str, + role_assignment_schedule_request_name: str, + parameters: "_models.RoleAssignmentScheduleRequest", + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": """Creates a role assignment schedule request. :param scope: The scope of the role assignment schedule request to create. The scope can be any @@ -63,11 +212,12 @@ def create( '/providers/Microsoft.Subscription/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}' for a resource. :type scope: str - :param role_assignment_schedule_request_name: The name of the role assignment to create. It can - be any valid GUID. + :param role_assignment_schedule_request_name: A GUID for the role assignment to create. The + name must be unique and different for each role assignment. :type role_assignment_schedule_request_name: str :param parameters: Parameters for the role assignment schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentScheduleRequest, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequest @@ -78,32 +228,28 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentScheduleRequest') + + request = build_create_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -116,15 +262,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_assignment_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentScheduleRequest" + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentScheduleRequest": """Get the specified role assignment schedule request. :param scope: The scope of the role assignment schedule request. @@ -142,27 +290,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,15 +320,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentScheduleRequestListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentScheduleRequestListResult"]: """Gets role assignment schedule requests for a scope. :param scope: The scope of the role assignments schedule requests. @@ -194,48 +341,49 @@ def list_for_scope( Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests - where the current user is an approver. + where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] + :return: An iterator like instance of either RoleAssignmentScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleRequestListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -244,7 +392,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,18 +405,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests"} # type: ignore - def cancel( + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_assignment_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + scope: str, + role_assignment_schedule_request_name: str, + **kwargs: Any + ) -> None: """Cancels a pending role assignment schedule request. :param scope: The scope of the role assignment request to cancel. @@ -282,27 +435,24 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleRequestName': self._serialize.url("role_assignment_schedule_request_name", role_assignment_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + scope=scope, + role_assignment_schedule_request_name=role_assignment_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,4 +462,5 @@ def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentScheduleRequests/{roleAssignmentScheduleRequestName}/cancel"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py index 459616f2e5c0..20a2026fee03 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignment_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_assignment_schedule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentScheduleName": _SERIALIZER.url("role_assignment_schedule_name", role_assignment_schedule_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentSchedulesOperations(object): """RoleAssignmentSchedulesOperations operations. @@ -45,13 +117,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - role_assignment_schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentSchedule" + scope: str, + role_assignment_schedule_name: str, + **kwargs: Any + ) -> "_models.RoleAssignmentSchedule": """Get the specified role assignment schedule for a resource scope. :param scope: The scope of the role assignment schedule. @@ -68,27 +140,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentScheduleName': self._serialize.url("role_assignment_schedule_name", role_assignment_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_schedule_name=role_assignment_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,15 +170,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules/{roleAssignmentScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentScheduleListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentScheduleListResult"]: """Gets role assignment schedules for a resource scope. :param scope: The scope of the role assignments schedules. @@ -119,47 +190,49 @@ def list_for_scope( assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] + :return: An iterator like instance of either RoleAssignmentScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +254,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentSchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py index 08463b4693be..5820f4af3838 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,503 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_subscription_request( + subscription_id: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_resource_request( + subscription_id: str, + resource_group_name: str, + resource_provider_namespace: str, + resource_type: str, + resource_name: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str', skip_quote=True), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_assignment_name: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_validate_request( + scope: str, + role_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleAssignmentName": _SERIALIZER.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + role_assignment_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_by_id_request( + role_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_by_id_request( + role_assignment_id: str, + *, + tenant_id: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if tenant_id is not None: + _query_parameters['tenantId'] = _SERIALIZER.query("tenant_id", tenant_id, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_validate_by_id_request( + role_assignment_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{roleAssignmentId}/validate") + path_format_arguments = { + "roleAssignmentId": _SERIALIZER.url("role_assignment_id", role_assignment_id, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class RoleAssignmentsOperations(object): """RoleAssignmentsOperations operations. @@ -45,63 +526,64 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_subscription( self, - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """List all role assignments that apply to a subscription. :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,82 +592,89 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """List all role assignments that apply 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 filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,32 +683,37 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def list_for_resource( self, - resource_group_name, # type: str - resource_provider_namespace, # type: str - resource_type, # type: str - resource_name, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + resource_group_name: str, + resource_provider_namespace: str, + resource_type: str, + resource_name: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """List all role assignments that apply to a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. @@ -233,56 +727,61 @@ def list_for_resource( :type resource_name: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str', skip_quote=True), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str', skip_quote=True), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_resource_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + resource_type=resource_type, + resource_name=resource_name, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -291,29 +790,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_resource.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.RoleAssignment": """Get a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -323,7 +827,7 @@ def get( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -335,34 +839,30 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(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 tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -371,16 +871,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + scope: str, + role_assignment_name: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Create or update a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -391,7 +893,8 @@ def create( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment @@ -402,37 +905,33 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -445,16 +944,18 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def delete( self, - scope, # type: str - role_assignment_name, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + scope: str, + role_assignment_name: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Delete a role assignment by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -464,7 +965,7 @@ def delete( :type scope: str :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -476,34 +977,30 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(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 tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -514,16 +1011,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}"} # type: ignore + + + @distributed_trace def validate( self, - scope, # type: str - role_assignment_name, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidationResponse" + scope: str, + role_assignment_name: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.ValidationResponse": """Validate a role assignment create or update operation by scope and name. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -534,7 +1033,8 @@ def validate( :param role_assignment_name: The name of the role assignment. It can be any valid GUID. :type role_assignment_name: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse @@ -545,37 +1045,33 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleAssignmentName': self._serialize.url("role_assignment_name", role_assignment_name, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_request( + scope=scope, + role_assignment_name=role_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -584,16 +1080,18 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized - validate.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate'} # type: ignore + validate.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}/validate"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentListResult"] + scope: str, + filter: Optional[str] = None, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentListResult"]: """List all role assignments that apply to a scope. :param scope: The scope of the operation or resource. Valid scopes are: subscription (format: @@ -603,52 +1101,53 @@ def list_for_scope( :type scope: str :param filter: The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role - assignments at, above or below the scope for the specified principal. + assignments at, above or below the scope for the specified principal. Default value is None. :type filter: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] + :return: An iterator like instance of either RoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_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', skip_quote=True) - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + tenant_id=tenant_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -657,28 +1156,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignments"} # type: ignore + @distributed_trace def get_by_id( self, - role_assignment_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_assignment_id: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> "_models.RoleAssignment": """Get a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -686,7 +1190,7 @@ def get_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -698,33 +1202,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignment', pipeline_response) @@ -733,15 +1233,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + get_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def create_by_id( self, - role_assignment_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignment" + role_assignment_id: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.RoleAssignment": """Create or update a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -750,7 +1252,8 @@ def create_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignment @@ -761,36 +1264,32 @@ def create_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_create_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -803,15 +1302,17 @@ def create_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + create_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def delete_by_id( self, - role_assignment_id, # type: str - tenant_id=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.RoleAssignment"] + role_assignment_id: str, + tenant_id: Optional[str] = None, + **kwargs: Any + ) -> Optional["_models.RoleAssignment"]: """Delete a role assignment by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -819,7 +1320,7 @@ def delete_by_id( /{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}. Example: /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str - :param tenant_id: Tenant ID for cross-tenant request. + :param tenant_id: Tenant ID for cross-tenant request. Default value is None. :type tenant_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignment, or the result of cls(response) @@ -831,33 +1332,29 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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') - if tenant_id is not None: - query_parameters['tenantId'] = self._serialize.query("tenant_id", tenant_id, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + tenant_id=tenant_id, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -868,15 +1365,17 @@ def delete_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - delete_by_id.metadata = {'url': '/{roleAssignmentId}'} # type: ignore + delete_by_id.metadata = {'url': "/{roleAssignmentId}"} # type: ignore + + + @distributed_trace def validate_by_id( self, - role_assignment_id, # type: str - parameters, # type: "_models.RoleAssignmentCreateParameters" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidationResponse" + role_assignment_id: str, + parameters: "_models.RoleAssignmentCreateParameters", + **kwargs: Any + ) -> "_models.ValidationResponse": """Validate a role assignment create or update operation by ID. :param role_assignment_id: The fully qualified ID of the role assignment including scope, @@ -885,7 +1384,8 @@ def validate_by_id( /subscriptions/:code:``/resourcegroups/:code:``/providers/Microsoft.Authorization/roleAssignments/:code:``. :type role_assignment_id: str :param parameters: Parameters for the role assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleAssignmentCreateParameters :keyword callable cls: A custom type or function that will be passed the direct response :return: ValidationResponse, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.ValidationResponse @@ -896,36 +1396,32 @@ def validate_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'roleAssignmentId': self._serialize.url("role_assignment_id", role_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleAssignmentCreateParameters') + + request = build_validate_by_id_request( + role_assignment_id=role_assignment_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.validate_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidationResponse', pipeline_response) @@ -934,4 +1430,6 @@ def validate_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - validate_by_id.metadata = {'url': '/{roleAssignmentId}/validate'} # type: ignore + + validate_by_id.metadata = {'url': "/{roleAssignmentId}/validate"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py index 0d44db0bf21b..a26bb703db7c 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_request( + scope: str, + role_eligibility_schedule_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleInstanceName": _SERIALIZER.url("role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleEligibilityScheduleInstancesOperations(object): """RoleEligibilityScheduleInstancesOperations operations. @@ -45,13 +117,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleEligibilityScheduleInstanceListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleEligibilityScheduleInstanceListResult"]: """Gets role eligibility schedule instances of a role eligibility schedule. :param scope: The scope of the role eligibility schedule. @@ -61,47 +133,49 @@ def list_for_scope( assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] + :return: An iterator like instance of either RoleEligibilityScheduleInstanceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleInstanceListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,7 +184,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,18 +197,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances"} # type: ignore + @distributed_trace def get( self, - scope, # type: str - role_eligibility_schedule_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilityScheduleInstance" + scope: str, + role_eligibility_schedule_instance_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleInstance": """Gets the specified role eligibility schedule instance. :param scope: The scope of the role eligibility schedules. @@ -148,27 +227,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleInstanceName': self._serialize.url("role_eligibility_schedule_instance_name", role_eligibility_schedule_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_instance_name=role_eligibility_schedule_instance_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,4 +257,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}'} # type: ignore + + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleInstances/{roleEligibilityScheduleInstanceName}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py index ea97a5f68681..f22046189cfc 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedule_requests_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,171 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request( + scope: str, + role_eligibility_schedule_request_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_cancel_request( + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleRequestName": _SERIALIZER.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleEligibilityScheduleRequestsOperations(object): """RoleEligibilityScheduleRequestsOperations operations. @@ -45,14 +194,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create( self, - scope, # type: str - role_eligibility_schedule_request_name, # type: str - parameters, # type: "_models.RoleEligibilityScheduleRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilityScheduleRequest" + scope: str, + role_eligibility_schedule_request_name: str, + parameters: "_models.RoleEligibilityScheduleRequest", + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": """Creates a role eligibility schedule request. :param scope: The scope of the role eligibility schedule request to create. The scope can be @@ -67,7 +216,8 @@ def create( can be any valid GUID. :type role_eligibility_schedule_request_name: str :param parameters: Parameters for the role eligibility schedule request. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleEligibilityScheduleRequest, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequest @@ -78,32 +228,28 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleEligibilityScheduleRequest') + + request = build_create_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -116,15 +262,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace def get( self, - scope, # type: str - role_eligibility_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilityScheduleRequest" + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilityScheduleRequest": """Get the specified role eligibility schedule request. :param scope: The scope of the role eligibility schedule request. @@ -142,27 +290,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -175,15 +320,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleEligibilityScheduleRequestListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleEligibilityScheduleRequestListResult"]: """Gets role eligibility schedule requests for a scope. :param scope: The scope of the role eligibility schedule requests. @@ -194,48 +341,49 @@ def list_for_scope( principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule - requests where the current user is an approver. + requests where the current user is an approver. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] + :return: An iterator like instance of either RoleEligibilityScheduleRequestListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleRequestListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleRequestListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleRequestListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleRequestListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -244,7 +392,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,18 +405,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests"} # type: ignore - def cancel( + @distributed_trace + def cancel( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_eligibility_schedule_request_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + scope: str, + role_eligibility_schedule_request_name: str, + **kwargs: Any + ) -> None: """Cancels a pending role eligibility schedule request. :param scope: The scope of the role eligibility request to cancel. @@ -282,27 +435,24 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleRequestName': self._serialize.url("role_eligibility_schedule_request_name", role_eligibility_schedule_request_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + scope=scope, + role_eligibility_schedule_request_name=role_eligibility_schedule_request_name, + api_version=api_version, + template_url=self.cancel.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -312,4 +462,5 @@ def cancel( if cls: return cls(pipeline_response, None, {}) - cancel.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel'} # type: ignore + cancel.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/{roleEligibilityScheduleRequestName}/cancel"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py index a3d1b5ff8321..c4ece195569a 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_eligibility_schedules_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_eligibility_schedule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleEligibilityScheduleName": _SERIALIZER.url("role_eligibility_schedule_name", role_eligibility_schedule_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleEligibilitySchedulesOperations(object): """RoleEligibilitySchedulesOperations operations. @@ -45,13 +117,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - role_eligibility_schedule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleEligibilitySchedule" + scope: str, + role_eligibility_schedule_name: str, + **kwargs: Any + ) -> "_models.RoleEligibilitySchedule": """Get the specified role eligibility schedule for a resource scope. :param scope: The scope of the role eligibility schedule. @@ -68,27 +140,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleEligibilityScheduleName': self._serialize.url("role_eligibility_schedule_name", role_eligibility_schedule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_eligibility_schedule_name=role_eligibility_schedule_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,15 +170,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules/{roleEligibilityScheduleName}"} # type: ignore + + + @distributed_trace def list_for_scope( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleEligibilityScheduleListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleEligibilityScheduleListResult"]: """Gets role eligibility schedules for a resource scope. :param scope: The scope of the role eligibility schedules. @@ -119,47 +190,49 @@ def list_for_scope( eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. + Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] + :return: An iterator like instance of either RoleEligibilityScheduleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleEligibilityScheduleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleEligibilityScheduleListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleEligibilityScheduleListResult', pipeline_response) + deserialized = self._deserialize("RoleEligibilityScheduleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,7 +241,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -177,7 +254,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleEligibilitySchedules"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py index bbf34302c894..efebd5df0fad 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policies_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_management_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_update_request( + scope: str, + role_management_policy_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_management_policy_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyName": _SERIALIZER.url("role_management_policy_name", role_management_policy_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleManagementPoliciesOperations(object): """RoleManagementPoliciesOperations operations. @@ -45,13 +190,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - role_management_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicy" + scope: str, + role_management_policy_name: str, + **kwargs: Any + ) -> "_models.RoleManagementPolicy": """Get the specified role management policy for a resource scope. :param scope: The scope of the role management policy. @@ -68,27 +213,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -101,16 +243,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace def update( self, - scope, # type: str - role_management_policy_name, # type: str - parameters, # type: "_models.RoleManagementPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicy" + scope: str, + role_management_policy_name: str, + parameters: "_models.RoleManagementPolicy", + **kwargs: Any + ) -> "_models.RoleManagementPolicy": """Update a role management policy. :param scope: The scope of the role management policy to upsert. @@ -129,32 +273,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicy') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicy') + + request = build_update_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -167,15 +307,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore - def delete( + update.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_management_policy_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + scope: str, + role_management_policy_name: str, + **kwargs: Any + ) -> None: """Delete a role management policy. :param scope: The scope of the role management policy to upsert. @@ -192,27 +334,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyName': self._serialize.url("role_management_policy_name", role_management_policy_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_management_policy_name=role_management_policy_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -222,56 +361,58 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies/{roleManagementPolicyName}"} # type: ignore + + @distributed_trace def list_for_scope( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleManagementPolicyListResult"] + scope: str, + **kwargs: Any + ) -> Iterable["_models.RoleManagementPolicyListResult"]: """Gets role management policies for a resource scope. :param scope: The scope of the role management policy. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicyListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] + :return: An iterator like instance of either RoleManagementPolicyListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -280,7 +421,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -289,7 +434,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicies'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicies"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py index fea0ec5db6e3..d3abba08382f 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2020_10_01_preview/operations/_role_management_policy_assignments_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,167 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyAssignmentName": _SERIALIZER.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + scope: str, + role_management_policy_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyAssignmentName": _SERIALIZER.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + "roleManagementPolicyAssignmentName": _SERIALIZER.url("role_management_policy_assignment_name", role_management_policy_assignment_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_list_for_scope_request( + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleManagementPolicyAssignmentsOperations(object): """RoleManagementPolicyAssignmentsOperations operations. @@ -45,13 +190,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - scope, # type: str - role_management_policy_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicyAssignment" + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any + ) -> "_models.RoleManagementPolicyAssignment": """Get the specified role management policy assignment for a resource scope. :param scope: The scope of the role management policy. @@ -69,27 +214,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_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') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,16 +244,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + get.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace def create( self, - scope, # type: str - role_management_policy_assignment_name, # type: str - parameters, # type: "_models.RoleManagementPolicyAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleManagementPolicyAssignment" + scope: str, + role_management_policy_assignment_name: str, + parameters: "_models.RoleManagementPolicyAssignment", + **kwargs: Any + ) -> "_models.RoleManagementPolicyAssignment": """Create a role management policy assignment. :param scope: The scope of the role management policy assignment to upsert. @@ -120,7 +264,8 @@ def create( management policy assignment to upsert. :type role_management_policy_assignment_name: str :param parameters: Parameters for the role management policy assignment. - :type parameters: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment + :type parameters: + ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleManagementPolicyAssignment, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignment @@ -131,32 +276,28 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_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'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'RoleManagementPolicyAssignment') + + request = build_create_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [201]: @@ -169,15 +310,17 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore - def delete( + create.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, - scope, # type: str - role_management_policy_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + scope: str, + role_management_policy_assignment_name: str, + **kwargs: Any + ) -> None: """Delete a role management policy assignment. :param scope: The scope of the role management policy assignment to delete. @@ -195,27 +338,24 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - 'roleManagementPolicyAssignmentName': self._serialize.url("role_management_policy_assignment_name", role_management_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') + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + scope=scope, + role_management_policy_assignment_name=role_management_policy_assignment_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -225,56 +365,58 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}'} # type: ignore + delete.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments/{roleManagementPolicyAssignmentName}"} # type: ignore + + @distributed_trace def list_for_scope( self, - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleManagementPolicyAssignmentListResult"] + scope: str, + **kwargs: Any + ) -> Iterable["_models.RoleManagementPolicyAssignmentListResult"]: """Gets role management assignment policies for a resource scope. :param scope: The scope of the role management policy. :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] + :return: An iterator like instance of either RoleManagementPolicyAssignmentListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2020_10_01_preview.models.RoleManagementPolicyAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2020-10-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleManagementPolicyAssignmentListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_for_scope.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=self.list_for_scope.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_for_scope_request( + scope=scope, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleManagementPolicyAssignmentListResult', pipeline_response) + deserialized = self._deserialize("RoleManagementPolicyAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -283,7 +425,11 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -292,7 +438,8 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) - list_for_scope.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments'} # type: ignore + list_for_scope.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleManagementPolicyAssignments"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py index 9ef3cafd5e61..b1727ad25141 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_authorization_management_client.py @@ -6,97 +6,103 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import RoleAssignmentApprovalOperations -from .operations import RoleAssignmentApprovalStepsOperations -from .operations import RoleAssignmentApprovalStepOperations -from .operations import ScopeRoleAssignmentApprovalOperations -from .operations import ScopeRoleAssignmentApprovalStepsOperations -from .operations import ScopeRoleAssignmentApprovalStepOperations from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import Operations, RoleAssignmentApprovalOperations, RoleAssignmentApprovalStepOperations, RoleAssignmentApprovalStepsOperations, ScopeRoleAssignmentApprovalOperations, ScopeRoleAssignmentApprovalStepOperations, ScopeRoleAssignmentApprovalStepsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Request Approvals service provides the workflow for running request approvals on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Request Approvals service provides the workflow for running request approvals on different kind + of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.operations.Operations :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations - :vartype role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalOperations + :vartype role_assignment_approval: + azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalOperations :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations - :vartype role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepsOperations + :vartype role_assignment_approval_steps: + azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepsOperations :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations - :vartype role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepOperations + :vartype role_assignment_approval_step: + azure.mgmt.authorization.v2021_01_01_preview.operations.RoleAssignmentApprovalStepOperations :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations - :vartype scope_role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalOperations - :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations operations - :vartype scope_role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepsOperations + :vartype scope_role_assignment_approval: + azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalOperations + :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations + operations + :vartype scope_role_assignment_approval_steps: + azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepsOperations :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations - :vartype scope_role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepOperations + :vartype scope_role_assignment_approval_step: + azure.mgmt.authorization.v2021_01_01_preview.operations.ScopeRoleAssignmentApprovalStepOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( 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 = AuthorizationManagementClientConfiguration(credential, **kwargs) + credential: "TokenCredential", + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval = RoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) + - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py index 95df76e19b26..e70a52bca679 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,20 +27,24 @@ class AuthorizationManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2021-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -62,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json index 143a0ba7ab5f..c3054bf380f0 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Request Approvals service provides the workflow for running request approvals on different kind of resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py index 4d7b16fdf35a..fc6a285783a5 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_authorization_management_client.py @@ -6,93 +6,103 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import RoleAssignmentApprovalOperations -from .operations import RoleAssignmentApprovalStepsOperations -from .operations import RoleAssignmentApprovalStepOperations -from .operations import ScopeRoleAssignmentApprovalOperations -from .operations import ScopeRoleAssignmentApprovalStepsOperations -from .operations import ScopeRoleAssignmentApprovalStepOperations from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import Operations, RoleAssignmentApprovalOperations, RoleAssignmentApprovalStepOperations, RoleAssignmentApprovalStepsOperations, ScopeRoleAssignmentApprovalOperations, ScopeRoleAssignmentApprovalStepOperations, ScopeRoleAssignmentApprovalStepsOperations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Request Approvals service provides the workflow for running request approvals on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Request Approvals service provides the workflow for running request approvals on different kind + of resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.Operations :ivar role_assignment_approval: RoleAssignmentApprovalOperations operations - :vartype role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations + :vartype role_assignment_approval: + azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalOperations :ivar role_assignment_approval_steps: RoleAssignmentApprovalStepsOperations operations - :vartype role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations + :vartype role_assignment_approval_steps: + azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepsOperations :ivar role_assignment_approval_step: RoleAssignmentApprovalStepOperations operations - :vartype role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations + :vartype role_assignment_approval_step: + azure.mgmt.authorization.v2021_01_01_preview.aio.operations.RoleAssignmentApprovalStepOperations :ivar scope_role_assignment_approval: ScopeRoleAssignmentApprovalOperations operations - :vartype scope_role_assignment_approval: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations - :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations operations - :vartype scope_role_assignment_approval_steps: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations + :vartype scope_role_assignment_approval: + azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalOperations + :ivar scope_role_assignment_approval_steps: ScopeRoleAssignmentApprovalStepsOperations + operations + :vartype scope_role_assignment_approval_steps: + azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepsOperations :ivar scope_role_assignment_approval_step: ScopeRoleAssignmentApprovalStepOperations operations - :vartype scope_role_assignment_approval_step: azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations + :vartype scope_role_assignment_approval_step: + azure.mgmt.authorization.v2021_01_01_preview.aio.operations.ScopeRoleAssignmentApprovalStepOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval = RoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations(self._client, self._config, self._serialize, self._deserialize) + self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval = RoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_steps = RoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.role_assignment_approval_step = RoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval = ScopeRoleAssignmentApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_steps = ScopeRoleAssignmentApprovalStepsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.scope_role_assignment_approval_step = ScopeRoleAssignmentApprovalStepOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py index bb368f50e812..b39becd2588e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,6 +27,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :keyword api_version: Api Version. Default value is "2021-01-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -34,12 +37,14 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential - self.api_version = "2021-01-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -58,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py index 86197f34d0c0..a666679cb142 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py index 0e6672403f1e..d6a0bcc1fe20 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_approval_operations import build_get_by_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, @@ -55,44 +60,47 @@ def list( $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests - targeted for. + targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,21 +109,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -135,31 +149,28 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + approval_id=approval_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -168,4 +179,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py index 041f280a3e39..76d96b00fd43 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_step_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_approval_step_operations import build_get_by_id_request, build_patch_request, build_put_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -62,32 +66,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -96,8 +97,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def patch( self, approval_id: str, @@ -112,7 +116,8 @@ async def patch( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -123,37 +128,33 @@ async def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -162,8 +163,11 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def put( self, approval_id: str, @@ -178,7 +182,8 @@ async def put( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -189,37 +194,33 @@ async def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -228,4 +229,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py index 746cf0564221..9b02ce71ed26 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_role_assignment_approval_steps_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._role_assignment_approval_steps_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, approval_id: str, @@ -51,7 +55,8 @@ async def list( :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult, or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] @@ -59,31 +64,28 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_request( + approval_id=approval_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -92,4 +94,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py index ac2f82cdfe79..034d1f4cb462 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._scope_role_assignment_approval_operations import build_get_by_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, scope: str, @@ -58,48 +63,49 @@ def list( $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests - targeted for. + targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,21 +114,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -145,32 +157,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + approval_id=approval_id, + scope=scope, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -179,4 +188,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py index e5134c9426a1..b70f24a046a9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_step_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._scope_role_assignment_approval_step_operations import build_get_by_id_request, build_patch_request, build_put_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_id( self, approval_id: str, @@ -65,33 +69,30 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -100,8 +101,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def patch( self, approval_id: str, @@ -119,7 +123,8 @@ async def patch( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -130,38 +135,34 @@ async def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -170,8 +171,11 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace_async async def put( self, approval_id: str, @@ -189,7 +193,8 @@ async def put( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -200,38 +205,34 @@ async def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -240,4 +241,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py index d6b9c1f103b2..d9f99256f8db 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/aio/operations/_scope_role_assignment_approval_steps_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._scope_role_assignment_approval_steps_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, approval_id: str, @@ -54,7 +58,8 @@ async def list( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult, or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] @@ -62,32 +67,29 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_request( + approval_id=approval_id, + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -96,4 +98,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py index 6bfcb58bfb9a..33229e80b925 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/__init__.py @@ -6,28 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorDefinitionProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import RoleAssignmentApproval - from ._models_py3 import RoleAssignmentApprovalListResult - from ._models_py3 import RoleAssignmentApprovalStep - from ._models_py3 import RoleAssignmentApprovalStepListResult - from ._models_py3 import RoleAssignmentApprovalStepProperties -except (SyntaxError, ImportError): - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RoleAssignmentApproval # type: ignore - from ._models import RoleAssignmentApprovalListResult # type: ignore - from ._models import RoleAssignmentApprovalStep # type: ignore - from ._models import RoleAssignmentApprovalStepListResult # type: ignore - from ._models import RoleAssignmentApprovalStepProperties # type: ignore +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDefinitionProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import RoleAssignmentApproval +from ._models_py3 import RoleAssignmentApprovalListResult +from ._models_py3 import RoleAssignmentApprovalStep +from ._models_py3 import RoleAssignmentApprovalStepListResult +from ._models_py3 import RoleAssignmentApprovalStepProperties + from ._authorization_management_client_enums import ( RoleAssignmentApprovalActorIdentityType, diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py index c02590626aa8..4ab4ff550b5b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_authorization_management_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class RoleAssignmentApprovalActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class RoleAssignmentApprovalStepReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalStepReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny """ @@ -42,7 +27,7 @@ class RoleAssignmentApprovalStepReviewResult(with_metaclass(_CaseInsensitiveEnum DENY = "Deny" NOT_REVIEWED = "NotReviewed" -class RoleAssignmentApprovalStepStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoleAssignmentApprovalStepStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an approval. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py deleted file mode 100644 index 88eb0cd0d103..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models.py +++ /dev/null @@ -1,416 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorDefinitionProperties(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :param code: Error code of list gateway. - :type code: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinitionProperties, self).__init__(**kwargs) - self.message = None - self.code = kwargs.get('code', None) - - -class Operation(msrest.serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay - :param origin: Origin of the operation. Values include user|system|user,system. - :type origin: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :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 RoleAssignmentApproval(msrest.serialization.Model): - """Role Assignment Approval. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment approval id. - :vartype id: str - :ivar name: The role assignment approval unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param stages: This is the collection of stages returned when one does an expand on it. - :type stages: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'stages': {'key': 'properties.stages', 'type': '[RoleAssignmentApprovalStep]'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentApproval, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.stages = kwargs.get('stages', None) - - -class RoleAssignmentApprovalListResult(msrest.serialization.Model): - """List of role assignment approvals. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Role Assignment Approval list. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] - :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': '[RoleAssignmentApproval]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentApprovalListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RoleAssignmentApprovalStep(msrest.serialization.Model): - """Role assignment approval stage properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The role assignment approval stage id. - :vartype id: str - :ivar name: The role assignment approval stage name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param display_name: The display name for the approval stage. - :type display_name: str - :ivar status: This read-only field specifies the status of an approval. Possible values - include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", - "Completing", "Escalated". - :vartype status: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus - :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. - :vartype assigned_to_me: bool - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :param review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", - "Deny", "NotReviewed". - :type review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'assigned_to_me': {'readonly': True}, - 'reviewed_date_time': {'readonly': True}, - 'principal_id': {'readonly': True}, - 'principal_type': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'assigned_to_me': {'key': 'properties.assignedToMe', 'type': 'bool'}, - 'reviewed_date_time': {'key': 'properties.reviewedDateTime', 'type': 'iso-8601'}, - 'review_result': {'key': 'properties.reviewResult', 'type': 'str'}, - 'justification': {'key': 'properties.justification', 'type': 'str'}, - 'principal_id': {'key': 'properties.reviewedBy.principalId', 'type': 'str'}, - 'principal_type': {'key': 'properties.reviewedBy.principalType', 'type': 'str'}, - 'principal_name': {'key': 'properties.reviewedBy.principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'properties.reviewedBy.userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentApprovalStep, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.status = None - self.assigned_to_me = None - self.reviewed_date_time = None - self.review_result = kwargs.get('review_result', None) - self.justification = kwargs.get('justification', None) - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class RoleAssignmentApprovalStepListResult(msrest.serialization.Model): - """List of role assignment approval stage list. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: Role Assignment Approval Step list. - :type value: - list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] - :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': '[RoleAssignmentApprovalStep]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentApprovalStepListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class RoleAssignmentApprovalStepProperties(msrest.serialization.Model): - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The display name for the approval stage. - :type display_name: str - :ivar status: This read-only field specifies the status of an approval. Possible values - include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", - "Completing", "Escalated". - :vartype status: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepStatus - :ivar assigned_to_me: Indicates whether the stage is assigned to me for review. - :vartype assigned_to_me: bool - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :param review_result: The decision on the approval stage. This value is initially set to - NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", - "Deny", "NotReviewed". - :type review_result: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - 'status': {'readonly': True}, - 'assigned_to_me': {'readonly': True}, - 'reviewed_date_time': {'readonly': True}, - 'principal_id': {'readonly': True}, - 'principal_type': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'assigned_to_me': {'key': 'assignedToMe', 'type': 'bool'}, - 'reviewed_date_time': {'key': 'reviewedDateTime', 'type': 'iso-8601'}, - 'review_result': {'key': 'reviewResult', 'type': 'str'}, - 'justification': {'key': 'justification', 'type': 'str'}, - 'principal_id': {'key': 'reviewedBy.principalId', 'type': 'str'}, - 'principal_type': {'key': 'reviewedBy.principalType', 'type': 'str'}, - 'principal_name': {'key': 'reviewedBy.principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'reviewedBy.userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoleAssignmentApprovalStepProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.status = None - self.assigned_to_me = None - self.reviewed_date_time = None - self.review_result = kwargs.get('review_result', None) - self.justification = kwargs.get('justification', None) - self.principal_id = None - self.principal_type = None - self.principal_name = None - self.user_principal_name = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py index f33ff8c7edcc..87ba11aa15dc 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/models/_models_py3.py @@ -17,8 +17,8 @@ class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why an operation failed. - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { @@ -31,6 +31,11 @@ def __init__( error: Optional["ErrorDefinitionProperties"] = None, **kwargs ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_01_01_preview.models.ErrorDefinitionProperties + """ super(ErrorDefinition, self).__init__(**kwargs) self.error = error @@ -42,8 +47,8 @@ class ErrorDefinitionProperties(msrest.serialization.Model): :ivar message: Description of the error. :vartype message: str - :param code: Error code of list gateway. - :type code: str + :ivar code: Error code of list gateway. + :vartype code: str """ _validation = { @@ -61,6 +66,10 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ super(ErrorDefinitionProperties, self).__init__(**kwargs) self.message = None self.code = code @@ -69,14 +78,14 @@ def __init__( class Operation(msrest.serialization.Model): """The definition of a Microsoft.Authorization operation. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay - :param origin: Origin of the operation. Values include user|system|user,system. - :type origin: str + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. Values include user|system|user,system. + :vartype origin: str """ _attribute_map = { @@ -95,6 +104,16 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.authorization.v2021_01_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. Values include user|system|user,system. + :paramtype origin: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -135,6 +154,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -145,10 +166,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The result of a request to list Microsoft.Authorization operations. - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str """ _attribute_map = { @@ -163,6 +184,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.Operation] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -179,8 +206,8 @@ class RoleAssignmentApproval(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param stages: This is the collection of stages returned when one does an expand on it. - :type stages: + :ivar stages: This is the collection of stages returned when one does an expand on it. + :vartype stages: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] """ @@ -203,6 +230,11 @@ def __init__( stages: Optional[List["RoleAssignmentApprovalStep"]] = None, **kwargs ): + """ + :keyword stages: This is the collection of stages returned when one does an expand on it. + :paramtype stages: + list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] + """ super(RoleAssignmentApproval, self).__init__(**kwargs) self.id = None self.name = None @@ -215,8 +247,9 @@ class RoleAssignmentApprovalListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Role Assignment Approval list. - :type value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] + :ivar value: Role Assignment Approval list. + :vartype value: + list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str """ @@ -236,6 +269,11 @@ def __init__( value: Optional[List["RoleAssignmentApproval"]] = None, **kwargs ): + """ + :keyword value: Role Assignment Approval list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApproval] + """ super(RoleAssignmentApprovalListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -252,8 +290,8 @@ class RoleAssignmentApprovalStep(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param display_name: The display name for the approval stage. - :type display_name: str + :ivar display_name: The display name for the approval stage. + :vartype display_name: str :ivar status: This read-only field specifies the status of an approval. Possible values include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", "Escalated". @@ -263,13 +301,13 @@ class RoleAssignmentApprovalStep(msrest.serialization.Model): :vartype assigned_to_me: bool :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime - :param review_result: The decision on the approval stage. This value is initially set to + :ivar review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", "NotReviewed". - :type review_result: str or + :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: @@ -319,6 +357,17 @@ def __init__( justification: Optional[str] = None, **kwargs ): + """ + :keyword display_name: The display name for the approval stage. + :paramtype display_name: str + :keyword review_result: The decision on the approval stage. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed". + :paramtype review_result: str or + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ super(RoleAssignmentApprovalStep, self).__init__(**kwargs) self.id = None self.name = None @@ -340,8 +389,8 @@ class RoleAssignmentApprovalStepListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: Role Assignment Approval Step list. - :type value: + :ivar value: Role Assignment Approval Step list. + :vartype value: list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] :ivar next_link: The URL to use for getting the next set of results. :vartype next_link: str @@ -362,6 +411,11 @@ def __init__( value: Optional[List["RoleAssignmentApprovalStep"]] = None, **kwargs ): + """ + :keyword value: Role Assignment Approval Step list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep] + """ super(RoleAssignmentApprovalStepListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -372,8 +426,8 @@ class RoleAssignmentApprovalStepProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The display name for the approval stage. - :type display_name: str + :ivar display_name: The display name for the approval stage. + :vartype display_name: str :ivar status: This read-only field specifies the status of an approval. Possible values include: "NotStarted", "InProgress", "Completed", "Expired", "Initializing", "Escalating", "Completing", "Escalated". @@ -383,13 +437,13 @@ class RoleAssignmentApprovalStepProperties(msrest.serialization.Model): :vartype assigned_to_me: bool :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime - :param review_result: The decision on the approval stage. This value is initially set to + :ivar review_result: The decision on the approval stage. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", "NotReviewed". - :type review_result: str or + :vartype review_result: str or ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: @@ -433,6 +487,17 @@ def __init__( justification: Optional[str] = None, **kwargs ): + """ + :keyword display_name: The display name for the approval stage. + :paramtype display_name: str + :keyword review_result: The decision on the approval stage. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed". + :paramtype review_result: str or + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ super(RoleAssignmentApprovalStepProperties, self).__init__(**kwargs) self.display_name = display_name self.status = None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py index 7e220da70af2..5094ab907e40 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py index 3aba6671037f..c4663ddda962 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,86 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + approval_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentApprovalOperations(object): """RoleAssignmentApprovalOperations operations. @@ -45,12 +109,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentApprovalListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentApprovalListResult"]: """Get role assignment approvals. :param filter: The filter to apply on the operation. Valid values for $filter are: @@ -60,44 +124,47 @@ def list( $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests - targeted for. + targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,27 +173,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace def get_by_id( self, - approval_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApproval" + approval_id: str, + **kwargs: Any + ) -> "_models.RoleAssignmentApproval": """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -141,31 +213,28 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + approval_id=approval_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -174,4 +243,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py index f7b151bea740..8af86b68eb49 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_step_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,142 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_id_request( + approval_id: str, + stage_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "stageId": _SERIALIZER.url("stage_id", stage_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_patch_request( + approval_id: str, + stage_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "stageId": _SERIALIZER.url("stage_id", stage_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_put_request( + approval_id: str, + stage_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "stageId": _SERIALIZER.url("stage_id", stage_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class RoleAssignmentApprovalStepOperations(object): """RoleAssignmentApprovalStepOperations operations. @@ -44,13 +165,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_id( self, - approval_id, # type: str - stage_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStep": """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -67,32 +188,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -101,16 +219,18 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def patch( self, - approval_id, # type: str - stage_id, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + properties: "_models.RoleAssignmentApprovalStepProperties", + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStep": """Record a decision. :param approval_id: The id of the role assignment approval. @@ -118,7 +238,8 @@ def patch( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -129,37 +250,33 @@ def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -168,16 +285,18 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def put( self, - approval_id, # type: str - stage_id, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + properties: "_models.RoleAssignmentApprovalStepProperties", + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStep": """Record a decision. :param approval_id: The id of the role assignment approval. @@ -185,7 +304,8 @@ def put( :param stage_id: The id of the role assignment approval stage. :type stage_id: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -196,37 +316,33 @@ def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -235,4 +351,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py index 9f1af04b4e06..99fcab8e938b 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_role_assignment_approval_steps_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,55 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + approval_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages") + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class RoleAssignmentApprovalStepsOperations(object): """RoleAssignmentApprovalStepsOperations operations. @@ -44,19 +78,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - approval_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStepListResult" + approval_id: str, + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStepListResult": """Get role assignment approval. :param approval_id: The id of the role assignment approval. :type approval_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult, or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] @@ -64,31 +99,28 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_request( + approval_id=approval_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -97,4 +129,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py index 9a21685006fc..25dbb2a3bce7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + scope: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals") + path_format_arguments = { + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + approval_id: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}") + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class ScopeRoleAssignmentApprovalOperations(object): """ScopeRoleAssignmentApprovalOperations operations. @@ -45,13 +117,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - scope, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.RoleAssignmentApprovalListResult"] + scope: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.RoleAssignmentApprovalListResult"]: """Get role assignment approvals. :param scope: The scope of the resource. @@ -63,48 +135,49 @@ def list( $filter=asCreatedBy() is provided, the returned list only includes all role assignment approvals that the calling user created requests for. If $filter=asTarget() is provided, the returned list only includes all role assignment approvals that the calling user has requests - targeted for. + targeted for. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] + :return: An iterator like instance of either RoleAssignmentApprovalListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + scope=scope, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('RoleAssignmentApprovalListResult', pipeline_response) + deserialized = self._deserialize("RoleAssignmentApprovalListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,28 +186,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals'} # type: ignore + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals"} # type: ignore + @distributed_trace def get_by_id( self, - approval_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApproval" + approval_id: str, + scope: str, + **kwargs: Any + ) -> "_models.RoleAssignmentApproval": """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -151,32 +229,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + approval_id=approval_id, + scope=scope, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApproval', pipeline_response) @@ -185,4 +260,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}'} # type: ignore + + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py index e883fa439610..4f43446e94a1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_step_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,148 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_id_request( + approval_id: str, + stage_id: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "stageId": _SERIALIZER.url("stage_id", stage_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_patch_request( + approval_id: str, + stage_id: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "stageId": _SERIALIZER.url("stage_id", stage_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_put_request( + approval_id: str, + stage_id: str, + scope: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "stageId": _SERIALIZER.url("stage_id", stage_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class ScopeRoleAssignmentApprovalStepOperations(object): """ScopeRoleAssignmentApprovalStepOperations operations. @@ -44,14 +171,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_id( self, - approval_id, # type: str - stage_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + scope: str, + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStep": """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -70,33 +197,30 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_get_by_id_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -105,17 +229,19 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + get_by_id.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def patch( self, - approval_id, # type: str - stage_id, # type: str - scope, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + scope: str, + properties: "_models.RoleAssignmentApprovalStepProperties", + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStep": """Record a decision. :param approval_id: The id of the role assignment approval. @@ -125,7 +251,8 @@ def patch( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -136,38 +263,34 @@ def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_patch_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -176,17 +299,19 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + patch.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + + + @distributed_trace def put( self, - approval_id, # type: str - stage_id, # type: str - scope, # type: str - properties, # type: "_models.RoleAssignmentApprovalStepProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStep" + approval_id: str, + stage_id: str, + scope: str, + properties: "_models.RoleAssignmentApprovalStepProperties", + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStep": """Record a decision. :param approval_id: The id of the role assignment approval. @@ -196,7 +321,8 @@ def put( :param scope: The scope of the resource. :type scope: str :param properties: Role Assignment Approval stage properties to put. - :type properties: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties + :type properties: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStep, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStep @@ -207,38 +333,34 @@ def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'stageId': self._serialize.url("stage_id", stage_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'RoleAssignmentApprovalStepProperties') + + request = build_put_request( + approval_id=approval_id, + stage_id=stage_id, + scope=scope, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStep', pipeline_response) @@ -247,4 +369,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}'} # type: ignore + + put.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages/{stageId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py index 5a02802fe664..c95eb7c7b570 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_01_01_preview/operations/_scope_role_assignment_approval_steps_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + approval_id: str, + scope: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages") # pylint: disable=line-too-long + path_format_arguments = { + "approvalId": _SERIALIZER.url("approval_id", approval_id, 'str'), + "scope": _SERIALIZER.url("scope", scope, 'str', skip_quote=True), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class ScopeRoleAssignmentApprovalStepsOperations(object): """ScopeRoleAssignmentApprovalStepsOperations operations. @@ -44,13 +80,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - approval_id, # type: str - scope, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RoleAssignmentApprovalStepListResult" + approval_id: str, + scope: str, + **kwargs: Any + ) -> "_models.RoleAssignmentApprovalStepListResult": """Get role assignment approval. :param approval_id: The id of the role assignment approval. @@ -59,7 +95,8 @@ def list( :type scope: str :keyword callable cls: A custom type or function that will be passed the direct response :return: RoleAssignmentApprovalStepListResult, or the result of cls(response) - :rtype: ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult + :rtype: + ~azure.mgmt.authorization.v2021_01_01_preview.models.RoleAssignmentApprovalStepListResult :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleAssignmentApprovalStepListResult"] @@ -67,32 +104,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'approvalId': self._serialize.url("approval_id", approval_id, 'str'), - 'scope': self._serialize.url("scope", scope, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-01-01-preview") # type: str + + + request = build_list_request( + approval_id=approval_id, + scope=scope, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RoleAssignmentApprovalStepListResult', pipeline_response) @@ -101,4 +135,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages'} # type: ignore + + list.metadata = {'url': "/{scope}/providers/Microsoft.Authorization/roleAssignmentApprovals/{approvalId}/stages"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py index ae11ad3e4d97..6bee2d262ef1 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AuthorizationManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py index 024c0891cf62..0f4d2bc9ee38 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_authorization_management_client.py @@ -6,113 +6,115 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import AccessReviewDefaultSettingsOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class AuthorizationManagementClient(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Access reviews service provides the workflow for running access reviews on different kind of + resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_03_01_preview.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewScheduleDefinitionsOperations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstancesOperations + :vartype access_review_instances: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceOperations + :vartype access_review_instance: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceDecisionsOperations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :vartype access_review_default_settings: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceMyDecisionsOperations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.v2021_03_01_preview.operations.AccessReviewInstanceMyDecisionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances = AccessReviewInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance = AccessReviewInstanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py index 06e446c95642..f00daf9b6e81 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_configuration.py @@ -6,22 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -31,24 +29,28 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +70,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json index b908ed305c6e..f6f32b346629 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "AuthorizationManagementClient", "filename": "_authorization_management_client", "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py index ffc49d028e42..e2872ec3f27d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._authorization_management_client import AuthorizationManagementClient __all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py index 3d185b7b8558..9a4c5b7723c2 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_authorization_management_client.py @@ -6,109 +6,115 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -from ._configuration import AuthorizationManagementClientConfiguration -from .operations import Operations -from .operations import AccessReviewScheduleDefinitionsOperations -from .operations import AccessReviewInstancesOperations -from .operations import AccessReviewInstanceOperations -from .operations import AccessReviewInstanceDecisionsOperations -from .operations import AccessReviewDefaultSettingsOperations -from .operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations -from .operations import AccessReviewInstancesAssignedForMyApprovalOperations -from .operations import AccessReviewInstanceMyDecisionsOperations from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import AccessReviewDefaultSettingsOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClient(object): - """Access reviews service provides the workflow for running access reviews on different kind of resources. +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Access reviews service provides the workflow for running access reviews on different kind of + resources. :ivar operations: Operations operations :vartype operations: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.Operations :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations - :vartype access_review_schedule_definitions: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations :ivar access_review_instances: AccessReviewInstancesOperations operations - :vartype access_review_instances: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesOperations + :vartype access_review_instances: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesOperations :ivar access_review_instance: AccessReviewInstanceOperations operations - :vartype access_review_instance: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceOperations + :vartype access_review_instance: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceOperations :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations - :vartype access_review_instance_decisions: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations - :vartype access_review_default_settings: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewDefaultSettingsOperations - :ivar access_review_schedule_definitions_assigned_for_my_approval: AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations - :vartype access_review_schedule_definitions_assigned_for_my_approval: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations - :ivar access_review_instances_assigned_for_my_approval: AccessReviewInstancesAssignedForMyApprovalOperations operations - :vartype access_review_instances_assigned_for_my_approval: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :vartype access_review_default_settings: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations - :vartype access_review_instance_my_decisions: azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.v2021_03_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AuthorizationManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances = AccessReviewInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance = AccessReviewInstanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances = AccessReviewInstancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance = AccessReviewInstanceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_default_settings = AccessReviewDefaultSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations( - self._client, self._config, self._serialize, self._deserialize) - self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py index 984ddf81ab63..5d093e186e98 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class AuthorizationManagementClientConfiguration(Configuration): +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for AuthorizationManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,6 +29,9 @@ class AuthorizationManagementClientConfiguration(Configuration): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-03-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +40,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + 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(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-03-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +69,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py index 07a4a1853c02..a9afb9bb7956 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_default_settings_operations import build_get_request, build_put_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, **kwargs: Any @@ -56,31 +60,28 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -89,8 +90,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace_async async def put( self, properties: "_models.AccessReviewScheduleSettings", @@ -99,7 +103,8 @@ async def put( """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings @@ -110,36 +115,32 @@ async def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -148,4 +149,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py index 46aa06675b42..1fe06881243d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instance_decisions_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -57,50 +61,53 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,17 +116,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py index 11b4e5669c57..8b622215cebe 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instance_my_decisions_operations import build_get_by_id_request, build_list_request, build_patch_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -57,49 +62,51 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,21 +115,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -148,33 +161,30 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -183,8 +193,11 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace_async async def patch( self, schedule_definition_id: str, @@ -202,7 +215,8 @@ async def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision @@ -213,38 +227,34 @@ async def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -253,4 +263,6 @@ async def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py index 05b717381d86..b51ebbfa9aec 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instance_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,16 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instance_operations import build_accept_recommendations_request, build_apply_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +43,8 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def stop( + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -62,41 +66,40 @@ async def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + - async def reset_decisions( + @distributed_trace_async + async def reset_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -118,41 +121,40 @@ async def reset_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + - async def apply_decisions( + @distributed_trace_async + async def apply_decisions( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -174,41 +176,40 @@ async def apply_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + - async def send_reminders( + @distributed_trace_async + async def send_reminders( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -230,41 +231,40 @@ async def send_reminders( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore - async def accept_recommendations( + + @distributed_trace_async + async def accept_recommendations( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, id: str, @@ -286,35 +286,33 @@ async def accept_recommendations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - accept_recommendations.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py index 51d114152204..9270b81029ca 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instances_assigned_for_my_approval_operations import build_get_by_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -54,48 +59,49 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,21 +110,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -141,32 +153,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -175,4 +184,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py index ac8213f00104..b31bd099ecbf 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_instances_operations import build_get_by_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, schedule_definition_id: str, @@ -54,49 +59,51 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,21 +112,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -142,33 +155,30 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -177,4 +187,6 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index af0a064b834a..e380f7704bf7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, @@ -51,44 +55,47 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +104,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py index d762fddac400..47412e667a4e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._access_review_schedule_definitions_operations import build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, @@ -51,48 +56,49 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,21 +107,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace_async async def get_by_id( self, schedule_definition_id: str, @@ -135,32 +147,29 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -169,9 +178,12 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -190,39 +202,38 @@ async def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace_async async def create_or_update_by_id( self, schedule_definition_id: str, @@ -234,7 +245,8 @@ async def create_or_update_by_id( :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition @@ -245,37 +257,33 @@ async def create_or_update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -284,9 +292,12 @@ async def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - async def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements self, schedule_definition_id: str, **kwargs: Any @@ -305,35 +316,33 @@ async def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py index 7dafd9b6b2b7..43d7db247221 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,17 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,38 +53,40 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -89,17 +95,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py index 61394ed229f2..a97906e4ebe9 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/__init__.py @@ -6,48 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AccessReviewDecision - from ._models_py3 import AccessReviewDecisionIdentity - from ._models_py3 import AccessReviewDecisionListResult - from ._models_py3 import AccessReviewDecisionProperties - from ._models_py3 import AccessReviewDecisionResource - from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity - from ._models_py3 import AccessReviewDecisionUserIdentity - from ._models_py3 import AccessReviewDefaultSettings - from ._models_py3 import AccessReviewInstance - from ._models_py3 import AccessReviewInstanceListResult - from ._models_py3 import AccessReviewReviewer - from ._models_py3 import AccessReviewScheduleDefinition - from ._models_py3 import AccessReviewScheduleDefinitionListResult - from ._models_py3 import AccessReviewScheduleDefinitionProperties - from ._models_py3 import AccessReviewScheduleSettings - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorDefinitionProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult -except (SyntaxError, ImportError): - from ._models import AccessReviewDecision # type: ignore - from ._models import AccessReviewDecisionIdentity # type: ignore - from ._models import AccessReviewDecisionListResult # type: ignore - from ._models import AccessReviewDecisionProperties # type: ignore - from ._models import AccessReviewDecisionResource # type: ignore - from ._models import AccessReviewDecisionServicePrincipalIdentity # type: ignore - from ._models import AccessReviewDecisionUserIdentity # type: ignore - from ._models import AccessReviewDefaultSettings # type: ignore - from ._models import AccessReviewInstance # type: ignore - from ._models import AccessReviewInstanceListResult # type: ignore - from ._models import AccessReviewReviewer # type: ignore - from ._models import AccessReviewScheduleDefinition # type: ignore - from ._models import AccessReviewScheduleDefinitionListResult # type: ignore - from ._models import AccessReviewScheduleDefinitionProperties # type: ignore - from ._models import AccessReviewScheduleSettings # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorDefinitionProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore +from ._models_py3 import AccessReviewDecision +from ._models_py3 import AccessReviewDecisionIdentity +from ._models_py3 import AccessReviewDecisionListResult +from ._models_py3 import AccessReviewDecisionProperties +from ._models_py3 import AccessReviewDecisionResource +from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity +from ._models_py3 import AccessReviewDecisionUserIdentity +from ._models_py3 import AccessReviewDefaultSettings +from ._models_py3 import AccessReviewInstance +from ._models_py3 import AccessReviewInstanceListResult +from ._models_py3 import AccessReviewReviewer +from ._models_py3 import AccessReviewScheduleDefinition +from ._models_py3 import AccessReviewScheduleDefinitionListResult +from ._models_py3 import AccessReviewScheduleDefinitionProperties +from ._models_py3 import AccessReviewScheduleSettings +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDefinitionProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult + from ._authorization_management_client_enums import ( AccessRecommendationType, diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py index 3342334011d4..087730f1c7a6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_authorization_management_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRecommendationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The feature- generated recommendation shown to the reviewer. """ @@ -34,14 +19,14 @@ class AccessRecommendationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu DENY = "Deny" NO_INFO_AVAILABLE = "NoInfoAvailable" -class AccessReviewActorIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewApplyResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The outcome of applying the decision. """ @@ -52,7 +37,7 @@ class AccessReviewApplyResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" APPLY_NOT_SUPPORTED = "ApplyNotSupported" -class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewInstanceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an access review instance. """ @@ -68,14 +53,14 @@ class AccessReviewInstanceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, E AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewRecurrencePatternType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrencePatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence type : weekly, monthly, etc. """ WEEKLY = "weekly" ABSOLUTE_MONTHLY = "absoluteMonthly" -class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewRecurrenceRangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The recurrence range type. The possible values are: endDate, noEnd, numbered. """ @@ -83,7 +68,7 @@ class AccessReviewRecurrenceRangeType(with_metaclass(_CaseInsensitiveEnumMeta, s NO_END = "noEnd" NUMBERED = "numbered" -class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny """ @@ -94,14 +79,14 @@ class AccessReviewResult(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DONT_KNOW = "DontKnow" NOT_NOTIFIED = "NotNotified" -class AccessReviewReviewerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewReviewerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type : user/servicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be chosen dynamically. For example managers review or self review. @@ -111,7 +96,7 @@ class AccessReviewScheduleDefinitionReviewersType(with_metaclass(_CaseInsensitiv SELF = "Self" MANAGERS = "Managers" -class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScheduleDefinitionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This read-only field specifies the status of an accessReview. """ @@ -127,14 +112,14 @@ class AccessReviewScheduleDefinitionStatus(with_metaclass(_CaseInsensitiveEnumMe AUTO_REVIEWED = "AutoReviewed" STARTING = "Starting" -class AccessReviewScopeAssignmentState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopeAssignmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The role assignment state eligible/active to review """ ELIGIBLE = "eligible" ACTIVE = "active" -class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessReviewScopePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type user/servicePrincipal to review """ @@ -142,20 +127,20 @@ class AccessReviewScopePrincipalType(with_metaclass(_CaseInsensitiveEnumMeta, st GUEST_USER = "guestUser" SERVICE_PRINCIPAL = "servicePrincipal" -class DecisionResourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of resource """ AZURE_ROLE = "azureRole" -class DecisionTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DecisionTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of decision target : User/ServicePrincipal """ USER = "user" SERVICE_PRINCIPAL = "servicePrincipal" -class DefaultDecisionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultDecisionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """This specifies the behavior for the autoReview feature when an access review completes. """ diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py deleted file mode 100644 index ae4866e63512..000000000000 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models.py +++ /dev/null @@ -1,1352 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AccessReviewDecision(msrest.serialization.Model): - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review decision id. - :vartype id: str - :ivar name: The access review decision name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_properties_applied_by_principal_id: The identity id. - :vartype principal_id_properties_applied_by_principal_id: str - :ivar principal_type_properties_applied_by_principal_type: The identity type : - user/servicePrincipal. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_applied_by_principal_name: The identity display name. - :vartype principal_name_properties_applied_by_principal_name: str - :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if - valid). - :vartype user_principal_name_properties_applied_by_user_principal_name: str - :ivar principal_id_properties_reviewed_by_principal_id: The identity id. - :vartype principal_id_properties_reviewed_by_principal_id: str - :ivar principal_type_properties_reviewed_by_principal_type: The identity type : - user/servicePrincipal. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. - :vartype principal_name_properties_reviewed_by_principal_name: str - :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal - name(if valid). - :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :param type_properties_resource_type: The type of resource.Constant filled by server. Possible - values include: "azureRole". - :type type_properties_resource_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType - :ivar id_properties_resource_id: The id of resource associated with a decision record. - :vartype id_properties_resource_id: str - :ivar display_name_properties_resource_display_name: The display name of resource associated - with a decision record. - :vartype display_name_properties_resource_display_name: str - :param type_properties_principal_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", - "servicePrincipal". - :type type_properties_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id_properties_principal_id: The id of principal whose access was reviewed. - :vartype id_properties_principal_id: str - :ivar display_name_properties_principal_display_name: The display name of the user whose access - was reviewed. - :vartype display_name_properties_principal_display_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'recommendation': {'readonly': True}, - 'reviewed_date_time': {'readonly': True}, - 'apply_result': {'readonly': True}, - 'applied_date_time': {'readonly': True}, - 'principal_id_properties_applied_by_principal_id': {'readonly': True}, - 'principal_type_properties_applied_by_principal_type': {'readonly': True}, - 'principal_name_properties_applied_by_principal_name': {'readonly': True}, - 'user_principal_name_properties_applied_by_user_principal_name': {'readonly': True}, - 'principal_id_properties_reviewed_by_principal_id': {'readonly': True}, - 'principal_type_properties_reviewed_by_principal_type': {'readonly': True}, - 'principal_name_properties_reviewed_by_principal_name': {'readonly': True}, - 'user_principal_name_properties_reviewed_by_user_principal_name': {'readonly': True}, - 'id_properties_resource_id': {'readonly': True}, - 'display_name_properties_resource_display_name': {'readonly': True}, - 'id_properties_principal_id': {'readonly': True}, - 'display_name_properties_principal_display_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, - 'decision': {'key': 'properties.decision', 'type': 'str'}, - 'justification': {'key': 'properties.justification', 'type': 'str'}, - 'reviewed_date_time': {'key': 'properties.reviewedDateTime', 'type': 'iso-8601'}, - 'apply_result': {'key': 'properties.applyResult', 'type': 'str'}, - 'applied_date_time': {'key': 'properties.appliedDateTime', 'type': 'iso-8601'}, - 'principal_id_properties_applied_by_principal_id': {'key': 'properties.appliedBy.principalId', 'type': 'str'}, - 'principal_type_properties_applied_by_principal_type': {'key': 'properties.appliedBy.principalType', 'type': 'str'}, - 'principal_name_properties_applied_by_principal_name': {'key': 'properties.appliedBy.principalName', 'type': 'str'}, - 'user_principal_name_properties_applied_by_user_principal_name': {'key': 'properties.appliedBy.userPrincipalName', 'type': 'str'}, - 'principal_id_properties_reviewed_by_principal_id': {'key': 'properties.reviewedBy.principalId', 'type': 'str'}, - 'principal_type_properties_reviewed_by_principal_type': {'key': 'properties.reviewedBy.principalType', 'type': 'str'}, - 'principal_name_properties_reviewed_by_principal_name': {'key': 'properties.reviewedBy.principalName', 'type': 'str'}, - 'user_principal_name_properties_reviewed_by_user_principal_name': {'key': 'properties.reviewedBy.userPrincipalName', 'type': 'str'}, - 'type_properties_resource_type': {'key': 'properties.resource.type', 'type': 'str'}, - 'id_properties_resource_id': {'key': 'properties.resource.id', 'type': 'str'}, - 'display_name_properties_resource_display_name': {'key': 'properties.resource.displayName', 'type': 'str'}, - 'type_properties_principal_type': {'key': 'properties.principal.type', 'type': 'str'}, - 'id_properties_principal_id': {'key': 'properties.principal.id', 'type': 'str'}, - 'display_name_properties_principal_display_name': {'key': 'properties.principal.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecision, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_properties_applied_by_principal_id = None - self.principal_type_properties_applied_by_principal_type = None - self.principal_name_properties_applied_by_principal_name = None - self.user_principal_name_properties_applied_by_user_principal_name = None - self.principal_id_properties_reviewed_by_principal_id = None - self.principal_type_properties_reviewed_by_principal_type = None - self.principal_name_properties_reviewed_by_principal_name = None - self.user_principal_name_properties_reviewed_by_user_principal_name = None - self.type_properties_resource_type = None # type: Optional[str] - self.id_properties_resource_id = None - self.display_name_properties_resource_display_name = None - self.type_properties_principal_type = None # type: Optional[str] - self.id_properties_principal_id = None - self.display_name_properties_principal_display_name = None - - -class AccessReviewDecisionIdentity(msrest.serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity. - - 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - """ - - _validation = { - 'type': {'required': True}, - 'id': {'readonly': True}, - 'display_name': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - _subtype_map = { - 'type': {'servicePrincipal': 'AccessReviewDecisionServicePrincipalIdentity', 'user': 'AccessReviewDecisionUserIdentity'} - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionIdentity, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.id = None - self.display_name = None - - -class AccessReviewDecisionListResult(msrest.serialization.Model): - """List of access review decisions. - - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewDecision]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewDecisionProperties(msrest.serialization.Model): - """Approval Step. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible - values include: "Approve", "Deny", "NoInfoAvailable". - :vartype recommendation: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. - Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", - "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str - :ivar reviewed_date_time: Date Time when a decision was taken. - :vartype reviewed_date_time: ~datetime.datetime - :ivar apply_result: The outcome of applying the decision. Possible values include: "New", - "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", - "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". - :vartype apply_result: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewApplyResult - :ivar applied_date_time: The date and time when the review decision was applied. - :vartype applied_date_time: ~datetime.datetime - :ivar principal_id_applied_by_principal_id: The identity id. - :vartype principal_id_applied_by_principal_id: str - :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_applied_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_applied_by_principal_name: The identity display name. - :vartype principal_name_applied_by_principal_name: str - :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_applied_by_user_principal_name: str - :ivar principal_id_reviewed_by_principal_id: The identity id. - :vartype principal_id_reviewed_by_principal_id: str - :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_reviewed_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name_reviewed_by_principal_name: The identity display name. - :vartype principal_name_reviewed_by_principal_name: str - :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). - :vartype user_principal_name_reviewed_by_user_principal_name: str - :param type_resource_type: The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type type_resource_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType - :ivar id_resource_id: The id of resource associated with a decision record. - :vartype id_resource_id: str - :ivar display_name_resource_display_name: The display name of resource associated with a - decision record. - :vartype display_name_resource_display_name: str - :param type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled - by server. Possible values include: "user", "servicePrincipal". - :type type_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id_principal_id: The id of principal whose access was reviewed. - :vartype id_principal_id: str - :ivar display_name_principal_display_name: The display name of the user whose access was - reviewed. - :vartype display_name_principal_display_name: str - """ - - _validation = { - 'recommendation': {'readonly': True}, - 'reviewed_date_time': {'readonly': True}, - 'apply_result': {'readonly': True}, - 'applied_date_time': {'readonly': True}, - 'principal_id_applied_by_principal_id': {'readonly': True}, - 'principal_type_applied_by_principal_type': {'readonly': True}, - 'principal_name_applied_by_principal_name': {'readonly': True}, - 'user_principal_name_applied_by_user_principal_name': {'readonly': True}, - 'principal_id_reviewed_by_principal_id': {'readonly': True}, - 'principal_type_reviewed_by_principal_type': {'readonly': True}, - 'principal_name_reviewed_by_principal_name': {'readonly': True}, - 'user_principal_name_reviewed_by_user_principal_name': {'readonly': True}, - 'id_resource_id': {'readonly': True}, - 'display_name_resource_display_name': {'readonly': True}, - 'id_principal_id': {'readonly': True}, - 'display_name_principal_display_name': {'readonly': True}, - } - - _attribute_map = { - 'recommendation': {'key': 'recommendation', 'type': 'str'}, - 'decision': {'key': 'decision', 'type': 'str'}, - 'justification': {'key': 'justification', 'type': 'str'}, - 'reviewed_date_time': {'key': 'reviewedDateTime', 'type': 'iso-8601'}, - 'apply_result': {'key': 'applyResult', 'type': 'str'}, - 'applied_date_time': {'key': 'appliedDateTime', 'type': 'iso-8601'}, - 'principal_id_applied_by_principal_id': {'key': 'appliedBy.principalId', 'type': 'str'}, - 'principal_type_applied_by_principal_type': {'key': 'appliedBy.principalType', 'type': 'str'}, - 'principal_name_applied_by_principal_name': {'key': 'appliedBy.principalName', 'type': 'str'}, - 'user_principal_name_applied_by_user_principal_name': {'key': 'appliedBy.userPrincipalName', 'type': 'str'}, - 'principal_id_reviewed_by_principal_id': {'key': 'reviewedBy.principalId', 'type': 'str'}, - 'principal_type_reviewed_by_principal_type': {'key': 'reviewedBy.principalType', 'type': 'str'}, - 'principal_name_reviewed_by_principal_name': {'key': 'reviewedBy.principalName', 'type': 'str'}, - 'user_principal_name_reviewed_by_user_principal_name': {'key': 'reviewedBy.userPrincipalName', 'type': 'str'}, - 'type_resource_type': {'key': 'resource.type', 'type': 'str'}, - 'id_resource_id': {'key': 'resource.id', 'type': 'str'}, - 'display_name_resource_display_name': {'key': 'resource.displayName', 'type': 'str'}, - 'type_principal_type': {'key': 'principal.type', 'type': 'str'}, - 'id_principal_id': {'key': 'principal.id', 'type': 'str'}, - 'display_name_principal_display_name': {'key': 'principal.displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionProperties, self).__init__(**kwargs) - self.recommendation = None - self.decision = kwargs.get('decision', None) - self.justification = kwargs.get('justification', None) - self.reviewed_date_time = None - self.apply_result = None - self.applied_date_time = None - self.principal_id_applied_by_principal_id = None - self.principal_type_applied_by_principal_type = None - self.principal_name_applied_by_principal_name = None - self.user_principal_name_applied_by_user_principal_name = None - self.principal_id_reviewed_by_principal_id = None - self.principal_type_reviewed_by_principal_type = None - self.principal_name_reviewed_by_principal_name = None - self.user_principal_name_reviewed_by_user_principal_name = None - self.type_resource_type = None # type: Optional[str] - self.id_resource_id = None - self.display_name_resource_display_name = None - self.type_principal_type = None # type: Optional[str] - self.id_principal_id = None - self.display_name_principal_display_name = None - - -class AccessReviewDecisionResource(msrest.serialization.Model): - """Target of the decision. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: . - - 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 type: Required. The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType - :ivar id: The id of resource associated with a decision record. - :vartype id: str - :ivar display_name: The display name of resource associated with a decision record. - :vartype display_name: str - """ - - _validation = { - 'type': {'required': True}, - 'id': {'readonly': True}, - 'display_name': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - _subtype_map = { - 'type': {} - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionResource, self).__init__(**kwargs) - self.type = None # type: Optional[str] - self.id = None - self.display_name = None - - -class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): - """Service Principal Decision Target. - - 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar app_id: The appId for the service principal entity being reviewed. - :vartype app_id: str - """ - - _validation = { - 'type': {'required': True}, - 'id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'app_id': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) - self.type = 'servicePrincipal' # type: str - self.app_id = None - - -class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): - """User Decision Target. - - 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType - :ivar id: The id of principal whose access was reviewed. - :vartype id: str - :ivar display_name: The display name of the user whose access was reviewed. - :vartype display_name: str - :ivar user_principal_name: The user principal name of the user whose access was reviewed. - :vartype user_principal_name: str - """ - - _validation = { - 'type': {'required': True}, - 'id': {'readonly': True}, - 'display_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'user_principal_name': {'key': 'userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) - self.type = 'user' # type: str - self.user_principal_name = None - - -class AccessReviewDefaultSettings(msrest.serialization.Model): - """Access Review Default Settings. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review default settings id. This is only going to be default. - :vartype id: str - :ivar name: The access review default settings name. This is always going to be Access Review - Default Settings. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values - are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'mail_notifications_enabled': {'key': 'properties.mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'properties.reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'properties.defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'properties.justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'properties.defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'properties.autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'properties.recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'properties.instanceDurationInDays', 'type': 'int'}, - 'type_properties_recurrence_range_type': {'key': 'properties.recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'properties.recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'properties.recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'properties.recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_properties_recurrence_pattern_type': {'key': 'properties.recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'properties.recurrence.pattern.interval', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewDefaultSettings, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_recurrence_range_type = kwargs.get('type_properties_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_recurrence_pattern_type = kwargs.get('type_properties_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class AccessReviewInstance(msrest.serialization.Model): - """Access Review Instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review instance id. - :vartype id: str - :ivar name: The access review instance name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :ivar status: This read-only field specifies the status of an access review instance. Possible - values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type end_date_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewInstance, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.status = None - self.start_date_time = kwargs.get('start_date_time', None) - self.end_date_time = kwargs.get('end_date_time', None) - - -class AccessReviewInstanceListResult(msrest.serialization.Model): - """List of Access Review Instances. - - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewInstanceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewReviewer(msrest.serialization.Model): - """Descriptor for what needs to be reviewed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str - :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: - "user", "servicePrincipal". - :vartype principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewerType - """ - - _validation = { - 'principal_type': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'principal_type': {'key': 'principalType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewReviewer, self).__init__(**kwargs) - self.principal_id = kwargs.get('principal_id', None) - self.principal_type = None - - -class AccessReviewScheduleDefinition(msrest.serialization.Model): - """Access Review Schedule Definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The access review schedule definition id. - :vartype id: str - :ivar name: The access review schedule definition unique id. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :param backup_reviewers: This is the collection of backup reviewers. - :type backup_reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a - review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be - assigned and instead be chosen dynamically. For example managers review or self review. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal - to review. Possible values include: "user", "guestUser", "servicePrincipal". - :vartype principal_type_properties_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Possible values - include: "eligible", "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible - values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, - etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_properties_created_by_principal_type: The identity type : - user/servicePrincipal. Possible values include: "user", "servicePrincipal". - :vartype principal_type_properties_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'status': {'readonly': True}, - 'reviewers_type': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'role_definition_id': {'readonly': True}, - 'principal_type_properties_scope_principal_type': {'readonly': True}, - 'assignment_state': {'readonly': True}, - 'principal_id': {'readonly': True}, - 'principal_type_properties_created_by_principal_type': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'description_for_admins': {'key': 'properties.descriptionForAdmins', 'type': 'str'}, - 'description_for_reviewers': {'key': 'properties.descriptionForReviewers', 'type': 'str'}, - 'reviewers': {'key': 'properties.reviewers', 'type': '[AccessReviewReviewer]'}, - 'backup_reviewers': {'key': 'properties.backupReviewers', 'type': '[AccessReviewReviewer]'}, - 'reviewers_type': {'key': 'properties.reviewersType', 'type': 'str'}, - 'instances': {'key': 'properties.instances', 'type': '[AccessReviewInstance]'}, - 'resource_id': {'key': 'properties.scope.resourceId', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.scope.roleDefinitionId', 'type': 'str'}, - 'principal_type_properties_scope_principal_type': {'key': 'properties.scope.principalType', 'type': 'str'}, - 'assignment_state': {'key': 'properties.scope.assignmentState', 'type': 'str'}, - 'inactive_duration': {'key': 'properties.scope.inactiveDuration', 'type': 'duration'}, - 'mail_notifications_enabled': {'key': 'properties.settings.mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'properties.settings.reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'properties.settings.defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'properties.settings.justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'properties.settings.defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'properties.settings.autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'properties.settings.recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'properties.settings.instanceDurationInDays', 'type': 'int'}, - 'type_properties_settings_recurrence_range_type': {'key': 'properties.settings.recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'properties.settings.recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'properties.settings.recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'properties.settings.recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_properties_settings_recurrence_pattern_type': {'key': 'properties.settings.recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'properties.settings.recurrence.pattern.interval', 'type': 'int'}, - 'principal_id': {'key': 'properties.createdBy.principalId', 'type': 'str'}, - 'principal_type_properties_created_by_principal_type': {'key': 'properties.createdBy.principalType', 'type': 'str'}, - 'principal_name': {'key': 'properties.createdBy.principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'properties.createdBy.userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinition, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.backup_reviewers = kwargs.get('backup_reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_properties_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = kwargs.get('inactive_duration', None) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_properties_settings_recurrence_range_type = kwargs.get('type_properties_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_properties_settings_recurrence_pattern_type = kwargs.get('type_properties_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_properties_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): - """List of Access Review Schedule Definitions. - - :param value: Access Review Schedule Definition list. - :type value: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AccessReviewScheduleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): - """Access Review. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The display name for the schedule definition. - :type display_name: str - :ivar status: This read-only field specifies the status of an accessReview. Possible values - include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", - "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". - :vartype status: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be - shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :param backup_reviewers: This is the collection of backup reviewers. - :type backup_reviewers: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a - review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be - assigned and instead be chosen dynamically. For example managers review or self review. - Possible values include: "Assigned", "Self", "Managers". - :vartype reviewers_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: - list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :ivar resource_id: ResourceId in which this review is getting created. - :vartype resource_id: str - :ivar role_definition_id: This is used to indicate the role being reviewed. - :vartype role_definition_id: str - :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. - Possible values include: "user", "guestUser", "servicePrincipal". - :vartype principal_type_scope_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopePrincipalType - :ivar assignment_state: The role assignment state eligible/active to review. Possible values - include: "eligible", "active". - :vartype assignment_state: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param inactive_duration: Duration users are inactive for. The value should be in ISO 8601 - format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert - TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, - seconds)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: - endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. - Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - :ivar principal_id: The identity id. - :vartype principal_id: str - :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. - Possible values include: "user", "servicePrincipal". - :vartype principal_type_created_by_principal_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewActorIdentityType - :ivar principal_name: The identity display name. - :vartype principal_name: str - :ivar user_principal_name: The user principal name(if valid). - :vartype user_principal_name: str - """ - - _validation = { - 'status': {'readonly': True}, - 'reviewers_type': {'readonly': True}, - 'resource_id': {'readonly': True}, - 'role_definition_id': {'readonly': True}, - 'principal_type_scope_principal_type': {'readonly': True}, - 'assignment_state': {'readonly': True}, - 'principal_id': {'readonly': True}, - 'principal_type_created_by_principal_type': {'readonly': True}, - 'principal_name': {'readonly': True}, - 'user_principal_name': {'readonly': True}, - } - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'description_for_admins': {'key': 'descriptionForAdmins', 'type': 'str'}, - 'description_for_reviewers': {'key': 'descriptionForReviewers', 'type': 'str'}, - 'reviewers': {'key': 'reviewers', 'type': '[AccessReviewReviewer]'}, - 'backup_reviewers': {'key': 'backupReviewers', 'type': '[AccessReviewReviewer]'}, - 'reviewers_type': {'key': 'reviewersType', 'type': 'str'}, - 'instances': {'key': 'instances', 'type': '[AccessReviewInstance]'}, - 'resource_id': {'key': 'scope.resourceId', 'type': 'str'}, - 'role_definition_id': {'key': 'scope.roleDefinitionId', 'type': 'str'}, - 'principal_type_scope_principal_type': {'key': 'scope.principalType', 'type': 'str'}, - 'assignment_state': {'key': 'scope.assignmentState', 'type': 'str'}, - 'inactive_duration': {'key': 'scope.inactiveDuration', 'type': 'duration'}, - 'mail_notifications_enabled': {'key': 'settings.mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'settings.reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'settings.defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'settings.justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'settings.defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'settings.autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'settings.recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'settings.instanceDurationInDays', 'type': 'int'}, - 'type_settings_recurrence_range_type': {'key': 'settings.recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'settings.recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'settings.recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'settings.recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_settings_recurrence_pattern_type': {'key': 'settings.recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'settings.recurrence.pattern.interval', 'type': 'int'}, - 'principal_id': {'key': 'createdBy.principalId', 'type': 'str'}, - 'principal_type_created_by_principal_type': {'key': 'createdBy.principalType', 'type': 'str'}, - 'principal_name': {'key': 'createdBy.principalName', 'type': 'str'}, - 'user_principal_name': {'key': 'createdBy.userPrincipalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.status = None - self.description_for_admins = kwargs.get('description_for_admins', None) - self.description_for_reviewers = kwargs.get('description_for_reviewers', None) - self.reviewers = kwargs.get('reviewers', None) - self.backup_reviewers = kwargs.get('backup_reviewers', None) - self.reviewers_type = None - self.instances = kwargs.get('instances', None) - self.resource_id = None - self.role_definition_id = None - self.principal_type_scope_principal_type = None - self.assignment_state = None - self.inactive_duration = kwargs.get('inactive_duration', None) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_settings_recurrence_range_type = kwargs.get('type_settings_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_settings_recurrence_pattern_type = kwargs.get('type_settings_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - self.principal_id = None - self.principal_type_created_by_principal_type = None - self.principal_name = None - self.user_principal_name = None - - -class AccessReviewScheduleSettings(msrest.serialization.Model): - """Settings of an Access Review. - - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the - review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to - reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a - justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to - pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access - review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to - automatically change the target object access resource, is enabled. If not enabled, a user - must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, - noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date - in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or - ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int - """ - - _attribute_map = { - 'mail_notifications_enabled': {'key': 'mailNotificationsEnabled', 'type': 'bool'}, - 'reminder_notifications_enabled': {'key': 'reminderNotificationsEnabled', 'type': 'bool'}, - 'default_decision_enabled': {'key': 'defaultDecisionEnabled', 'type': 'bool'}, - 'justification_required_on_approval': {'key': 'justificationRequiredOnApproval', 'type': 'bool'}, - 'default_decision': {'key': 'defaultDecision', 'type': 'str'}, - 'auto_apply_decisions_enabled': {'key': 'autoApplyDecisionsEnabled', 'type': 'bool'}, - 'recommendations_enabled': {'key': 'recommendationsEnabled', 'type': 'bool'}, - 'instance_duration_in_days': {'key': 'instanceDurationInDays', 'type': 'int'}, - 'type_recurrence_range_type': {'key': 'recurrence.range.type', 'type': 'str'}, - 'number_of_occurrences': {'key': 'recurrence.range.numberOfOccurrences', 'type': 'int'}, - 'start_date': {'key': 'recurrence.range.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'recurrence.range.endDate', 'type': 'iso-8601'}, - 'type_recurrence_pattern_type': {'key': 'recurrence.pattern.type', 'type': 'str'}, - 'interval': {'key': 'recurrence.pattern.interval', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(AccessReviewScheduleSettings, self).__init__(**kwargs) - self.mail_notifications_enabled = kwargs.get('mail_notifications_enabled', None) - self.reminder_notifications_enabled = kwargs.get('reminder_notifications_enabled', None) - self.default_decision_enabled = kwargs.get('default_decision_enabled', None) - self.justification_required_on_approval = kwargs.get('justification_required_on_approval', None) - self.default_decision = kwargs.get('default_decision', None) - self.auto_apply_decisions_enabled = kwargs.get('auto_apply_decisions_enabled', None) - self.recommendations_enabled = kwargs.get('recommendations_enabled', None) - self.instance_duration_in_days = kwargs.get('instance_duration_in_days', None) - self.type_recurrence_range_type = kwargs.get('type_recurrence_range_type', None) - self.number_of_occurrences = kwargs.get('number_of_occurrences', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.type_recurrence_pattern_type = kwargs.get('type_recurrence_pattern_type', None) - self.interval = kwargs.get('interval', None) - - -class ErrorDefinition(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorDefinitionProperties(msrest.serialization.Model): - """Error description and code explaining why an operation failed. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar message: Description of the error. - :vartype message: str - :param code: Error code of list gateway. - :type code: str - """ - - _validation = { - 'message': {'readonly': True}, - } - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinitionProperties, self).__init__(**kwargs) - self.message = None - self.code = kwargs.get('code', None) - - -class Operation(msrest.serialization.Model): - """The definition of a Microsoft.Authorization operation. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - - -class OperationDisplay(msrest.serialization.Model): - """The display information for a Microsoft.Authorization operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The resource provider name: Microsoft.Authorization. - :vartype provider: str - :ivar resource: The resource on which the operation is performed. - :vartype resource: str - :ivar operation: The operation that users can perform. - :vartype operation: str - :ivar description: The description for the operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The result of a request to list Microsoft.Authorization operations. - - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :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/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py index 830c5a8f66dd..fa3f8120071e 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/models/_models_py3.py @@ -30,12 +30,13 @@ class AccessReviewDecision(msrest.serialization.Model): values include: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :vartype decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Possible values include: "New", @@ -67,19 +68,19 @@ class AccessReviewDecision(msrest.serialization.Model): :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_properties_reviewed_by_user_principal_name: str - :param type_properties_resource_type: The type of resource.Constant filled by server. Possible + :ivar type_properties_resource_type: The type of resource.Constant filled by server. Possible values include: "azureRole". - :type type_properties_resource_type: str or + :vartype type_properties_resource_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType :ivar id_properties_resource_id: The id of resource associated with a decision record. :vartype id_properties_resource_id: str :ivar display_name_properties_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_properties_resource_display_name: str - :param type_properties_principal_type: The type of decision target : - User/ServicePrincipal.Constant filled by server. Possible values include: "user", + :ivar type_properties_principal_type: The type of decision target : + User/ServicePrincipal.Constant filled by server. Possible values include: "user", "servicePrincipal". - :type type_properties_principal_type: str or + :vartype type_properties_principal_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType :ivar id_properties_principal_id: The id of principal whose access was reviewed. :vartype id_properties_principal_id: str @@ -143,6 +144,15 @@ def __init__( justification: Optional[str] = None, **kwargs ): + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed", "DontKnow", "NotNotified". + :paramtype decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ super(AccessReviewDecision, self).__init__(**kwargs) self.id = None self.name = None @@ -179,9 +189,9 @@ class AccessReviewDecisionIdentity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. @@ -208,6 +218,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionIdentity, self).__init__(**kwargs) self.type = None # type: Optional[str] self.id = None @@ -217,10 +229,10 @@ def __init__( class AccessReviewDecisionListResult(msrest.serialization.Model): """List of access review decisions. - :param value: Access Review Decision list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Access Review Decision list. + :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -235,6 +247,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Access Review Decision list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AccessReviewDecisionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -249,12 +268,13 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): values include: "Approve", "Deny", "NoInfoAvailable". :vartype recommendation: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessRecommendationType - :param decision: The decision on the approval step. This value is initially set to NotReviewed. + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", "NotReviewed", "DontKnow", "NotNotified". - :type decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult - :param justification: Justification provided by approvers for their action. - :type justification: str + :vartype decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str :ivar reviewed_date_time: Date Time when a decision was taken. :vartype reviewed_date_time: ~datetime.datetime :ivar apply_result: The outcome of applying the decision. Possible values include: "New", @@ -284,18 +304,18 @@ class AccessReviewDecisionProperties(msrest.serialization.Model): :vartype principal_name_reviewed_by_principal_name: str :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). :vartype user_principal_name_reviewed_by_user_principal_name: str - :param type_resource_type: The type of resource.Constant filled by server. Possible values + :ivar type_resource_type: The type of resource.Constant filled by server. Possible values include: "azureRole". - :type type_resource_type: str or + :vartype type_resource_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType :ivar id_resource_id: The id of resource associated with a decision record. :vartype id_resource_id: str :ivar display_name_resource_display_name: The display name of resource associated with a decision record. :vartype display_name_resource_display_name: str - :param type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled - by server. Possible values include: "user", "servicePrincipal". - :type type_principal_type: str or + :ivar type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled + by server. Possible values include: "user", "servicePrincipal". + :vartype type_principal_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType :ivar id_principal_id: The id of principal whose access was reviewed. :vartype id_principal_id: str @@ -353,6 +373,15 @@ def __init__( justification: Optional[str] = None, **kwargs ): + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed", "DontKnow", "NotNotified". + :paramtype decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ super(AccessReviewDecisionProperties, self).__init__(**kwargs) self.recommendation = None self.decision = decision @@ -386,9 +415,9 @@ class AccessReviewDecisionResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of resource.Constant filled by server. Possible values - include: "azureRole". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType + :ivar type: Required. The type of resource.Constant filled by server. Possible values include: + "azureRole". + :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionResourceType :ivar id: The id of resource associated with a decision record. :vartype id: str :ivar display_name: The display name of resource associated with a decision record. @@ -415,6 +444,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionResource, self).__init__(**kwargs) self.type = None # type: Optional[str] self.id = None @@ -428,9 +459,9 @@ class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity) All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. @@ -457,6 +488,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) self.type = 'servicePrincipal' # type: str self.app_id = None @@ -469,9 +502,9 @@ class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): All required parameters must be populated in order to send to Azure. - :param type: Required. The type of decision target : User/ServicePrincipal.Constant filled by - server. Possible values include: "user", "servicePrincipal". - :type type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType + :ivar type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DecisionTargetType :ivar id: The id of principal whose access was reviewed. :vartype id: str :ivar display_name: The display name of the user whose access was reviewed. @@ -498,6 +531,8 @@ def __init__( self, **kwargs ): + """ + """ super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) self.type = 'user' # type: str self.user_principal_name = None @@ -515,50 +550,50 @@ class AccessReviewDefaultSettings(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_recurrence_range_type: The recurrence range type. The possible values + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_recurrence_range_type: str or + :vartype type_properties_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_recurrence_pattern_type: str or + :vartype type_properties_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _validation = { @@ -606,6 +641,53 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_properties_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :paramtype type_properties_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewDefaultSettings, self).__init__(**kwargs) self.id = None self.name = None @@ -642,10 +724,10 @@ class AccessReviewInstance(msrest.serialization.Model): "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceStatus - :param start_date_time: The DateTime when the review instance is scheduled to be start. - :type start_date_time: ~datetime.datetime - :param end_date_time: The DateTime when the review instance is scheduled to end. - :type end_date_time: ~datetime.datetime + :ivar start_date_time: The DateTime when the review instance is scheduled to be start. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The DateTime when the review instance is scheduled to end. + :vartype end_date_time: ~datetime.datetime """ _validation = { @@ -671,6 +753,12 @@ def __init__( end_date_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword start_date_time: The DateTime when the review instance is scheduled to be start. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The DateTime when the review instance is scheduled to end. + :paramtype end_date_time: ~datetime.datetime + """ super(AccessReviewInstance, self).__init__(**kwargs) self.id = None self.name = None @@ -683,10 +771,10 @@ def __init__( class AccessReviewInstanceListResult(msrest.serialization.Model): """List of Access Review Instances. - :param value: Access Review Instance list. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Access Review Instance list. + :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -701,6 +789,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Access Review Instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AccessReviewInstanceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -711,8 +806,8 @@ class AccessReviewReviewer(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param principal_id: The id of the reviewer(user/servicePrincipal). - :type principal_id: str + :ivar principal_id: The id of the reviewer(user/servicePrincipal). + :vartype principal_id: str :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: "user", "servicePrincipal". :vartype principal_type: str or @@ -734,6 +829,10 @@ def __init__( principal_id: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ super(AccessReviewReviewer, self).__init__(**kwargs) self.principal_id = principal_id self.principal_type = None @@ -750,24 +849,24 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param display_name: The display name for the schedule definition. - :type display_name: str + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Possible values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :param backup_reviewers: This is the collection of backup reviewers. - :type backup_reviewers: + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be @@ -775,8 +874,8 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): Possible values include: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str @@ -790,55 +889,55 @@ class AccessReviewScheduleDefinition(msrest.serialization.Model): include: "eligible", "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :vartype inactive_duration: ~datetime.timedelta + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_properties_settings_recurrence_range_type: The recurrence range type. The possible + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_properties_settings_recurrence_range_type: str or + :vartype type_properties_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values include: "weekly", "absoluteMonthly". - :type type_properties_settings_recurrence_pattern_type: str or + :vartype type_properties_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_properties_created_by_principal_type: The identity type : @@ -930,6 +1029,76 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The + possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", + "numbered". + :paramtype type_properties_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, + monthly, etc. Possible values include: "weekly", "absoluteMonthly". + :paramtype type_properties_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewScheduleDefinition, self).__init__(**kwargs) self.id = None self.name = None @@ -970,11 +1139,11 @@ def __init__( class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): """List of Access Review Schedule Definitions. - :param value: Access Review Schedule Definition list. - :type value: + :ivar value: Access Review Schedule Definition list. + :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _attribute_map = { @@ -989,6 +1158,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Access Review Schedule Definition list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -999,24 +1175,24 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The display name for the schedule definition. - :type display_name: str + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str :ivar status: This read-only field specifies the status of an accessReview. Possible values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". :vartype status: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionStatus - :param description_for_admins: The description provided by the access review creator and - visible to admins. - :type description_for_admins: str - :param description_for_reviewers: The description provided by the access review creator to be + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be shown to reviewers. - :type description_for_reviewers: str - :param reviewers: This is the collection of reviewers. - :type reviewers: + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] - :param backup_reviewers: This is the collection of backup reviewers. - :type backup_reviewers: + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be @@ -1024,8 +1200,8 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): Possible values include: "Assigned", "Self", "Managers". :vartype reviewers_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionReviewersType - :param instances: This is the collection of instances returned when one does an expand on it. - :type instances: + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] :ivar resource_id: ResourceId in which this review is getting created. :vartype resource_id: str @@ -1039,55 +1215,55 @@ class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): include: "eligible", "active". :vartype assignment_state: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScopeAssignmentState - :param inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, seconds)). - :type inactive_duration: ~datetime.timedelta - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :vartype inactive_duration: ~datetime.timedelta + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_settings_recurrence_range_type: The recurrence range type. The possible values are: + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_settings_recurrence_range_type: str or + :vartype type_settings_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values include: "weekly", "absoluteMonthly". - :type type_settings_recurrence_pattern_type: str or + :vartype type_settings_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int :ivar principal_id: The identity id. :vartype principal_id: str :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. @@ -1173,6 +1349,75 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: + list[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstance] + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :paramtype type_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) self.display_name = display_name self.status = None @@ -1210,50 +1455,50 @@ def __init__( class AccessReviewScheduleSettings(msrest.serialization.Model): """Settings of an Access Review. - :param mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the review creator is enabled. - :type mail_notifications_enabled: bool - :param reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to reviewers are enabled. - :type reminder_notifications_enabled: bool - :param default_decision_enabled: Flag to indicate whether reviewers are required to provide a + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a justification when reviewing access. - :type default_decision_enabled: bool - :param justification_required_on_approval: Flag to indicate whether the reviewer is required to + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to pass justification when recording a decision. - :type justification_required_on_approval: bool - :param default_decision: This specifies the behavior for the autoReview feature when an access + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access review completes. Possible values include: "Approve", "Deny", "Recommendation". - :type default_decision: str or + :vartype default_decision: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType - :param auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to automatically change the target object access resource, is enabled. If not enabled, a user must, after the review completes, apply the access review. - :type auto_apply_decisions_enabled: bool - :param recommendations_enabled: Flag to indicate whether showing recommendations to reviewers - is enabled. - :type recommendations_enabled: bool - :param instance_duration_in_days: The duration in days for an instance. - :type instance_duration_in_days: int - :param type_recurrence_range_type: The recurrence range type. The possible values are: endDate, + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". - :type type_recurrence_range_type: str or + :vartype type_recurrence_range_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType - :param number_of_occurrences: The number of times to repeat the access review. Required and - must be positive if type is numbered. - :type number_of_occurrences: int - :param start_date: The DateTime when the review is scheduled to be start. This could be a date + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date in the future. Required on create. - :type start_date: ~datetime.datetime - :param end_date: The DateTime when the review is scheduled to end. Required if type is endDate. - :type end_date: ~datetime.datetime - :param type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible - values include: "weekly", "absoluteMonthly". - :type type_recurrence_pattern_type: str or + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values + include: "weekly", "absoluteMonthly". + :vartype type_recurrence_pattern_type: str or ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType - :param interval: The interval for recurrence. For a quarterly review, the interval is 3 for - type : absoluteMonthly. - :type interval: int + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int """ _attribute_map = { @@ -1292,6 +1537,53 @@ def __init__( interval: Optional[int] = None, **kwargs ): + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_recurrence_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible + values include: "weekly", "absoluteMonthly". + :paramtype type_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ super(AccessReviewScheduleSettings, self).__init__(**kwargs) self.mail_notifications_enabled = mail_notifications_enabled self.reminder_notifications_enabled = reminder_notifications_enabled @@ -1312,8 +1604,8 @@ def __init__( class ErrorDefinition(msrest.serialization.Model): """Error description and code explaining why an operation failed. - :param error: Error of the list gateway status. - :type error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties """ _attribute_map = { @@ -1326,6 +1618,11 @@ def __init__( error: Optional["ErrorDefinitionProperties"] = None, **kwargs ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_03_01_preview.models.ErrorDefinitionProperties + """ super(ErrorDefinition, self).__init__(**kwargs) self.error = error @@ -1337,8 +1634,8 @@ class ErrorDefinitionProperties(msrest.serialization.Model): :ivar message: Description of the error. :vartype message: str - :param code: Error code of list gateway. - :type code: str + :ivar code: Error code of list gateway. + :vartype code: str """ _validation = { @@ -1356,6 +1653,10 @@ def __init__( code: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ super(ErrorDefinitionProperties, self).__init__(**kwargs) self.message = None self.code = code @@ -1364,14 +1665,14 @@ def __init__( class Operation(msrest.serialization.Model): """The definition of a Microsoft.Authorization operation. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Display of the operation. - :type display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay - :param origin: Origin of the operation. - :type origin: str + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str """ _attribute_map = { @@ -1390,6 +1691,16 @@ def __init__( origin: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.authorization.v2021_03_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -1430,6 +1741,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1440,10 +1753,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """The result of a request to list Microsoft.Authorization operations. - :param value: The collection value. - :type value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] - :param next_link: The URI that can be used to request the next set of paged results. - :type next_link: str + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype next_link: str """ _attribute_map = { @@ -1458,6 +1771,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.authorization.v2021_03_01_preview.models.Operation] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py index 232c1f8005ff..a9fe98e55fb6 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_default_settings_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewDefaultSettingsOperations(object): """AccessReviewDefaultSettingsOperations operations. @@ -44,11 +119,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": """Get access review default settings for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,31 +136,28 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -94,18 +166,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace def put( self, - properties, # type: "_models.AccessReviewScheduleSettings" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDefaultSettings" + properties: "_models.AccessReviewScheduleSettings", + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": """Get access review default settings for the subscription. :param properties: Access review schedule settings. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleSettings :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDefaultSettings, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDefaultSettings @@ -116,36 +191,32 @@ def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleSettings') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) @@ -154,4 +225,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default'} # type: ignore + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py index 3437cd4606f3..39aa7426278d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,64 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstanceDecisionsOperations(object): """AccessReviewInstanceDecisionsOperations operations. @@ -45,14 +87,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewDecisionListResult"]: """Get access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -62,50 +104,53 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,17 +159,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py index c48455101f10..48d0f085c496 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,143 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "decisionId": _SERIALIZER.url("decision_id", decision_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_patch_request( + schedule_definition_id: str, + id: str, + decision_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "decisionId": _SERIALIZER.url("decision_id", decision_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) class AccessReviewInstanceMyDecisionsOperations(object): """AccessReviewInstanceMyDecisionsOperations operations. @@ -45,14 +166,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewDecisionListResult"] + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewDecisionListResult"]: """Get my access review instance decisions. :param schedule_definition_id: The id of the access review schedule definition. @@ -62,49 +183,51 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewDecisionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewDecisionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,29 +236,34 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any + ) -> "_models.AccessReviewDecision": """Get my single access review instance decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -154,33 +282,30 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -189,17 +314,19 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace def patch( self, - schedule_definition_id, # type: str - id, # type: str - decision_id, # type: str - properties, # type: "_models.AccessReviewDecisionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewDecision" + schedule_definition_id: str, + id: str, + decision_id: str, + properties: "_models.AccessReviewDecisionProperties", + **kwargs: Any + ) -> "_models.AccessReviewDecision": """Record a decision. :param schedule_definition_id: The id of the access review schedule definition. @@ -209,7 +336,8 @@ def patch( :param decision_id: The id of the decision record. :type decision_id: str :param properties: Access review decision properties to patch. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecisionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewDecision, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewDecision @@ -220,38 +348,34 @@ def patch( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.patch.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'decisionId': self._serialize.url("decision_id", decision_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewDecisionProperties') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewDecision', pipeline_response) @@ -260,4 +384,6 @@ def patch( return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}'} # type: ignore + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py index fa1686655fbd..9b899e8780d7 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instance_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,22 +6,201 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_stop_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_reset_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_apply_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_send_reminders_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_accept_recommendations_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstanceOperations(object): """AccessReviewInstanceOperations operations. @@ -44,13 +224,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def stop( + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to stop an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -67,47 +247,45 @@ def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore - def reset_decisions( + + @distributed_trace + def reset_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to reset all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -124,47 +302,45 @@ def reset_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.reset_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - reset_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions'} # type: ignore + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + - def apply_decisions( + @distributed_trace + def apply_decisions( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to apply all decisions for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -181,47 +357,45 @@ def apply_decisions( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.apply_decisions.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - apply_decisions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions'} # type: ignore + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + - def send_reminders( + @distributed_trace + def send_reminders( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to send reminders for an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -238,47 +412,45 @@ def send_reminders( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.send_reminders.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - send_reminders.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders'} # type: ignore + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore - def accept_recommendations( + + @distributed_trace + def accept_recommendations( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: """An action to accept recommendations for decision in an access review instance. :param schedule_definition_id: The id of the access review schedule definition. @@ -295,35 +467,33 @@ def accept_recommendations( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.accept_recommendations.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - accept_recommendations.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations'} # type: ignore + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py index 793f76110420..7529e779c022 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,94 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstancesAssignedForMyApprovalOperations(object): """AccessReviewInstancesAssignedForMyApprovalOperations operations. @@ -45,13 +117,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewInstanceListResult"]: """Get access review instances assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,48 +131,49 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,28 +182,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": """Get single access review instance assigned for my approval. :param schedule_definition_id: The id of the access review schedule definition. @@ -147,32 +225,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -181,4 +256,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py index 4ab41b51436a..ba05f7f138de 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_instances_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewInstancesOperations(object): """AccessReviewInstancesOperations operations. @@ -45,13 +121,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - schedule_definition_id, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewInstanceListResult"] + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewInstanceListResult"]: """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -59,49 +135,51 @@ def list( :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewInstanceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewInstanceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewInstanceListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,28 +188,33 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewInstance" + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": """Get access review instances. :param schedule_definition_id: The id of the access review schedule definition. @@ -148,33 +231,30 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'id': self._serialize.url("id", id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewInstance', pipeline_response) @@ -183,4 +263,6 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}'} # type: ignore + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py index ad4b826a033e..501f6ebc7038 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,54 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations. @@ -45,55 +77,58 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"]: """Get access review instances assigned for my approval. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +137,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py index 53c36160607d..76f277eaff40 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,205 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request( + schedule_definition_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class AccessReviewScheduleDefinitionsOperations(object): """AccessReviewScheduleDefinitionsOperations operations. @@ -45,59 +228,60 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"] + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"]: """Get access review schedule definitions. :param filter: The filter to apply on the operation. Other than standard filters, one custom filter option is supported : 'assignedToMeToReview()'. When one specified $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are - returned. + returned. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AccessReviewScheduleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,27 +290,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + @distributed_trace def get_by_id( self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + schedule_definition_id: str, + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": """Get single access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -141,32 +330,29 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -175,14 +361,16 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def delete_by_id( + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Delete access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -197,52 +385,51 @@ def delete_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + @distributed_trace def create_or_update_by_id( self, - schedule_definition_id, # type: str - properties, # type: "_models.AccessReviewScheduleDefinitionProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.AccessReviewScheduleDefinition" + schedule_definition_id: str, + properties: "_models.AccessReviewScheduleDefinitionProperties", + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": """Create or Update access review schedule definition. :param schedule_definition_id: The id of the access review schedule definition. :type schedule_definition_id: str :param properties: Access review schedule definition properties. - :type properties: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties + :type properties: + ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinitionProperties :keyword callable cls: A custom type or function that will be passed the direct response :return: AccessReviewScheduleDefinition, or the result of cls(response) :rtype: ~azure.mgmt.authorization.v2021_03_01_preview.models.AccessReviewScheduleDefinition @@ -253,37 +440,33 @@ def create_or_update_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) @@ -292,14 +475,16 @@ def create_or_update_by_id( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}'} # type: ignore - def stop( + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements self, - schedule_definition_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + schedule_definition_id: str, + **kwargs: Any + ) -> None: """Stop access review definition. :param schedule_definition_id: The id of the access review schedule definition. @@ -314,35 +499,33 @@ def stop( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.stop.metadata['url'] # type: ignore - path_format_arguments = { - 'scheduleDefinitionId': self._serialize.url("schedule_definition_id", schedule_definition_id, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - stop.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop'} # type: ignore + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py index 52fa6e32a55b..d89f7cf9327d 100644 --- a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_03_01_preview/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,23 +6,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING -import warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,47 +73,49 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists the operations available from this provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_03_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ + api_version = kwargs.pop('api_version', "2021-03-01-preview") # type: str + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,17 +124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/providers/Microsoft.Authorization/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py new file mode 100644 index 000000000000..6bee2d262ef1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._authorization_management_client import AuthorizationManagementClient +from ._version import VERSION + +__version__ = VERSION +__all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py new file mode 100644 index 000000000000..6e540e750ac4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_authorization_management_client.py @@ -0,0 +1,140 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import AccessReviewDefaultSettingsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, TenantLevelAccessReviewInstanceContactedReviewersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Access reviews service provides the workflow for running access reviews on different kind of + resources. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.operations.Operations + :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsOperations + :ivar access_review_instances: AccessReviewInstancesOperations operations + :vartype access_review_instances: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesOperations + :ivar access_review_instance: AccessReviewInstanceOperations operations + :vartype access_review_instance: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceOperations + :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceDecisionsOperations + :ivar access_review_instance_contacted_reviewers: + AccessReviewInstanceContactedReviewersOperations operations + :vartype access_review_instance_contacted_reviewers: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceContactedReviewersOperations + :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations + :vartype access_review_default_settings: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.v2021_07_01_preview.operations.AccessReviewInstanceMyDecisionsOperations + :ivar tenant_level_access_review_instance_contacted_reviewers: + TenantLevelAccessReviewInstanceContactedReviewersOperations operations + :vartype tenant_level_access_review_instance_contacted_reviewers: + azure.mgmt.authorization.v2021_07_01_preview.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations + :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 base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances = AccessReviewInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance = AccessReviewInstanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_level_access_review_instance_contacted_reviewers = TenantLevelAccessReviewInstanceContactedReviewersOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AuthorizationManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py new file mode 100644 index 000000000000..7fd410e3c40c --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_configuration.py @@ -0,0 +1,73 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license 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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AuthorizationManagementClient. + + 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.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + 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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json new file mode 100644 index 000000000000..e4eaeedeb329 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_metadata.json @@ -0,0 +1,112 @@ +{ + "chosen_version": "2021-07-01-preview", + "total_api_version_list": ["2021-07-01-preview"], + "client": { + "name": "AuthorizationManagementClient", + "filename": "_authorization_management_client", + "description": "Access reviews service provides the workflow for running access reviews on different kind of resources.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AuthorizationManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "access_review_schedule_definitions": "AccessReviewScheduleDefinitionsOperations", + "access_review_instances": "AccessReviewInstancesOperations", + "access_review_instance": "AccessReviewInstanceOperations", + "access_review_instance_decisions": "AccessReviewInstanceDecisionsOperations", + "access_review_instance_contacted_reviewers": "AccessReviewInstanceContactedReviewersOperations", + "access_review_default_settings": "AccessReviewDefaultSettingsOperations", + "access_review_schedule_definitions_assigned_for_my_approval": "AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations", + "access_review_instances_assigned_for_my_approval": "AccessReviewInstancesAssignedForMyApprovalOperations", + "access_review_instance_my_decisions": "AccessReviewInstanceMyDecisionsOperations", + "tenant_level_access_review_instance_contacted_reviewers": "TenantLevelAccessReviewInstanceContactedReviewersOperations" + } +} \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/_version.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__init__.py new file mode 100644 index 000000000000..e2872ec3f27d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/__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_management_client import AuthorizationManagementClient +__all__ = ['AuthorizationManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py new file mode 100644 index 000000000000..8a3f7c9a6c63 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_authorization_management_client.py @@ -0,0 +1,137 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import AuthorizationManagementClientConfiguration +from .operations import AccessReviewDefaultSettingsOperations, AccessReviewInstanceContactedReviewersOperations, AccessReviewInstanceDecisionsOperations, AccessReviewInstanceMyDecisionsOperations, AccessReviewInstanceOperations, AccessReviewInstancesAssignedForMyApprovalOperations, AccessReviewInstancesOperations, AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations, AccessReviewScheduleDefinitionsOperations, Operations, TenantLevelAccessReviewInstanceContactedReviewersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AuthorizationManagementClient: # pylint: disable=too-many-instance-attributes + """Access reviews service provides the workflow for running access reviews on different kind of + resources. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.authorization.v2021_07_01_preview.aio.operations.Operations + :ivar access_review_schedule_definitions: AccessReviewScheduleDefinitionsOperations operations + :vartype access_review_schedule_definitions: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsOperations + :ivar access_review_instances: AccessReviewInstancesOperations operations + :vartype access_review_instances: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesOperations + :ivar access_review_instance: AccessReviewInstanceOperations operations + :vartype access_review_instance: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceOperations + :ivar access_review_instance_decisions: AccessReviewInstanceDecisionsOperations operations + :vartype access_review_instance_decisions: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceDecisionsOperations + :ivar access_review_instance_contacted_reviewers: + AccessReviewInstanceContactedReviewersOperations operations + :vartype access_review_instance_contacted_reviewers: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceContactedReviewersOperations + :ivar access_review_default_settings: AccessReviewDefaultSettingsOperations operations + :vartype access_review_default_settings: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewDefaultSettingsOperations + :ivar access_review_schedule_definitions_assigned_for_my_approval: + AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations operations + :vartype access_review_schedule_definitions_assigned_for_my_approval: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations + :ivar access_review_instances_assigned_for_my_approval: + AccessReviewInstancesAssignedForMyApprovalOperations operations + :vartype access_review_instances_assigned_for_my_approval: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstancesAssignedForMyApprovalOperations + :ivar access_review_instance_my_decisions: AccessReviewInstanceMyDecisionsOperations operations + :vartype access_review_instance_my_decisions: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.AccessReviewInstanceMyDecisionsOperations + :ivar tenant_level_access_review_instance_contacted_reviewers: + TenantLevelAccessReviewInstanceContactedReviewersOperations operations + :vartype tenant_level_access_review_instance_contacted_reviewers: + azure.mgmt.authorization.v2021_07_01_preview.aio.operations.TenantLevelAccessReviewInstanceContactedReviewersOperations + :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 base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AuthorizationManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions = AccessReviewScheduleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances = AccessReviewInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance = AccessReviewInstanceOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_decisions = AccessReviewInstanceDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_contacted_reviewers = AccessReviewInstanceContactedReviewersOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_default_settings = AccessReviewDefaultSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_schedule_definitions_assigned_for_my_approval = AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instances_assigned_for_my_approval = AccessReviewInstancesAssignedForMyApprovalOperations(self._client, self._config, self._serialize, self._deserialize) + self.access_review_instance_my_decisions = AccessReviewInstanceMyDecisionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_level_access_review_instance_contacted_reviewers = TenantLevelAccessReviewInstanceContactedReviewersOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AuthorizationManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..b3d884766ca4 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_configuration.py @@ -0,0 +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. +# Code generated 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 +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AuthorizationManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AuthorizationManagementClient. + + 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 + :keyword api_version: Api Version. Default value is "2021-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AuthorizationManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + 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.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-authorization/{}'.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.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..92ce9ac76bc5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations +from ._access_review_instances_operations import AccessReviewInstancesOperations +from ._access_review_instance_operations import AccessReviewInstanceOperations +from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations +from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations +from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations +from ._access_review_schedule_definitions_assigned_for_my_approval_operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations +from ._access_review_instances_assigned_for_my_approval_operations import AccessReviewInstancesAssignedForMyApprovalOperations +from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations +from ._tenant_level_access_review_instance_contacted_reviewers_operations import TenantLevelAccessReviewInstanceContactedReviewersOperations + +__all__ = [ + 'Operations', + 'AccessReviewScheduleDefinitionsOperations', + 'AccessReviewInstancesOperations', + 'AccessReviewInstanceOperations', + 'AccessReviewInstanceDecisionsOperations', + 'AccessReviewInstanceContactedReviewersOperations', + 'AccessReviewDefaultSettingsOperations', + 'AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations', + 'AccessReviewInstancesAssignedForMyApprovalOperations', + 'AccessReviewInstanceMyDecisionsOperations', + 'TenantLevelAccessReviewInstanceContactedReviewersOperations', +] diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py new file mode 100644 index 000000000000..77bb3806bba6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_default_settings_operations.py @@ -0,0 +1,154 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_default_settings_operations import build_get_request, build_put_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewDefaultSettingsOperations: + """AccessReviewDefaultSettingsOperations 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.authorization.v2021_07_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 + + @distributed_trace_async + async def get( + self, + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": + """Get access review default settings for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDefaultSettings, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace_async + async def put( + self, + properties: "_models.AccessReviewScheduleSettings", + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": + """Get access review default settings for the subscription. + + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDefaultSettings, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..2b7f56d4b139 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,129 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_instance_contacted_reviewers_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewInstanceContactedReviewersOperations: + """AccessReviewInstanceContactedReviewersOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewContactedReviewerListResult"]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..1be99769a187 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_decisions_operations.py @@ -0,0 +1,137 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_instance_decisions_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewInstanceDecisionsOperations: + """AccessReviewInstanceDecisionsOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewDecisionListResult"]: + """Get access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py new file mode 100644 index 000000000000..ab2c0afc66ca --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_my_decisions_operations.py @@ -0,0 +1,268 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_instance_my_decisions_operations import build_get_by_id_request, build_list_request, build_patch_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewInstanceMyDecisionsOperations: + """AccessReviewInstanceMyDecisionsOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewDecisionListResult"]: + """Get my access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any + ) -> "_models.AccessReviewDecision": + """Get my single access review instance decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDecision, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDecision', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace_async + async def patch( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + properties: "_models.AccessReviewDecisionProperties", + **kwargs: Any + ) -> "_models.AccessReviewDecision": + """Record a decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :param properties: Access review decision properties to patch. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDecision, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDecision', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py new file mode 100644 index 000000000000..8d2ba119263e --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instance_operations.py @@ -0,0 +1,318 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_instance_operations import build_accept_recommendations_request, build_apply_decisions_request, build_reset_decisions_request, build_send_reminders_request, build_stop_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewInstanceOperations: + """AccessReviewInstanceOperations 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.authorization.v2021_07_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 + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to stop an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + + + @distributed_trace_async + async def reset_decisions( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to reset all decisions for an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + + + @distributed_trace_async + async def apply_decisions( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to apply all decisions for an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + + + @distributed_trace_async + async def send_reminders( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to send reminders for an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore + + + @distributed_trace_async + async def accept_recommendations( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to accept recommendations for decision in an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..691c2846636a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,189 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_instances_assigned_for_my_approval_operations import build_get_by_id_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewInstancesAssignedForMyApprovalOperations: + """AccessReviewInstancesAssignedForMyApprovalOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewInstanceListResult"]: + """Get access review instances assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": + """Get single access review instance assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py new file mode 100644 index 000000000000..7cba643387c0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_instances_operations.py @@ -0,0 +1,259 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_instances_operations import build_create_request, build_get_by_id_request, build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewInstancesOperations: + """AccessReviewInstancesOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewInstanceListResult"]: + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + + + @distributed_trace_async + async def create( + self, + schedule_definition_id: str, + id: str, + properties: "_models.AccessReviewInstanceProperties", + **kwargs: Any + ) -> "_models.AccessReviewInstance": + """Update access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..8a82d0daa510 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -0,0 +1,125 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_schedule_definitions_assigned_for_my_approval_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations: + """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewScheduleDefinitionListResult"]: + """Get access review instances assigned for my approval. + + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..2e3c44a8af01 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_access_review_schedule_definitions_operations.py @@ -0,0 +1,348 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._access_review_schedule_definitions_operations import build_create_or_update_by_id_request, build_delete_by_id_request, build_get_by_id_request, build_list_request, build_stop_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AccessReviewScheduleDefinitionsOperations: + """AccessReviewScheduleDefinitionsOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewScheduleDefinitionListResult"]: + """Get access review schedule definitions. + + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + + @distributed_trace_async + async def get_by_id( + self, + schedule_definition_id: str, + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": + """Get single access review definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewScheduleDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Delete access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def create_or_update_by_id( + self, + schedule_definition_id: str, + properties: "_models.AccessReviewScheduleDefinitionProperties", + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": + """Create or Update access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewScheduleDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace_async + async def stop( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Stop access review definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py new file mode 100644 index 000000000000..cc157b2af9b1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_operations.py @@ -0,0 +1,116 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists the operations available from this provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..7030d3e67e7d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/aio/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,127 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._tenant_level_access_review_instance_contacted_reviewers_operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class TenantLevelAccessReviewInstanceContactedReviewersOperations: + """TenantLevelAccessReviewInstanceContactedReviewersOperations 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.authorization.v2021_07_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 + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> AsyncIterable["_models.AccessReviewContactedReviewerListResult"]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py new file mode 100644 index 000000000000..ab62ea79d1a0 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/__init__.py @@ -0,0 +1,93 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AccessReviewContactedReviewer +from ._models_py3 import AccessReviewContactedReviewerListResult +from ._models_py3 import AccessReviewDecision +from ._models_py3 import AccessReviewDecisionIdentity +from ._models_py3 import AccessReviewDecisionListResult +from ._models_py3 import AccessReviewDecisionProperties +from ._models_py3 import AccessReviewDecisionResource +from ._models_py3 import AccessReviewDecisionServicePrincipalIdentity +from ._models_py3 import AccessReviewDecisionUserIdentity +from ._models_py3 import AccessReviewDefaultSettings +from ._models_py3 import AccessReviewInstance +from ._models_py3 import AccessReviewInstanceListResult +from ._models_py3 import AccessReviewInstanceProperties +from ._models_py3 import AccessReviewReviewer +from ._models_py3 import AccessReviewScheduleDefinition +from ._models_py3 import AccessReviewScheduleDefinitionListResult +from ._models_py3 import AccessReviewScheduleDefinitionProperties +from ._models_py3 import AccessReviewScheduleSettings +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDefinitionProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult + + +from ._authorization_management_client_enums import ( + AccessRecommendationType, + AccessReviewActorIdentityType, + AccessReviewApplyResult, + AccessReviewInstanceReviewersType, + AccessReviewInstanceStatus, + AccessReviewRecurrencePatternType, + AccessReviewRecurrenceRangeType, + AccessReviewResult, + AccessReviewReviewerType, + AccessReviewScheduleDefinitionReviewersType, + AccessReviewScheduleDefinitionStatus, + AccessReviewScopeAssignmentState, + AccessReviewScopePrincipalType, + DecisionResourceType, + DecisionTargetType, + DefaultDecisionType, +) + +__all__ = [ + 'AccessReviewContactedReviewer', + 'AccessReviewContactedReviewerListResult', + 'AccessReviewDecision', + 'AccessReviewDecisionIdentity', + 'AccessReviewDecisionListResult', + 'AccessReviewDecisionProperties', + 'AccessReviewDecisionResource', + 'AccessReviewDecisionServicePrincipalIdentity', + 'AccessReviewDecisionUserIdentity', + 'AccessReviewDefaultSettings', + 'AccessReviewInstance', + 'AccessReviewInstanceListResult', + 'AccessReviewInstanceProperties', + 'AccessReviewReviewer', + 'AccessReviewScheduleDefinition', + 'AccessReviewScheduleDefinitionListResult', + 'AccessReviewScheduleDefinitionProperties', + 'AccessReviewScheduleSettings', + 'ErrorDefinition', + 'ErrorDefinitionProperties', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'AccessRecommendationType', + 'AccessReviewActorIdentityType', + 'AccessReviewApplyResult', + 'AccessReviewInstanceReviewersType', + 'AccessReviewInstanceStatus', + 'AccessReviewRecurrencePatternType', + 'AccessReviewRecurrenceRangeType', + 'AccessReviewResult', + 'AccessReviewReviewerType', + 'AccessReviewScheduleDefinitionReviewersType', + 'AccessReviewScheduleDefinitionStatus', + 'AccessReviewScopeAssignmentState', + 'AccessReviewScopePrincipalType', + 'DecisionResourceType', + 'DecisionTargetType', + 'DefaultDecisionType', +] diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py new file mode 100644 index 000000000000..d3d0204e32a1 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_authorization_management_client_enums.py @@ -0,0 +1,161 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRecommendationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The feature- generated recommendation shown to the reviewer. + """ + + APPROVE = "Approve" + DENY = "Deny" + NO_INFO_AVAILABLE = "NoInfoAvailable" + +class AccessReviewActorIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type : user/servicePrincipal + """ + + USER = "user" + SERVICE_PRINCIPAL = "servicePrincipal" + +class AccessReviewApplyResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The outcome of applying the decision. + """ + + NEW = "New" + APPLYING = "Applying" + APPLIED_SUCCESSFULLY = "AppliedSuccessfully" + APPLIED_WITH_UNKNOWN_FAILURE = "AppliedWithUnknownFailure" + APPLIED_SUCCESSFULLY_BUT_OBJECT_NOT_FOUND = "AppliedSuccessfullyButObjectNotFound" + APPLY_NOT_SUPPORTED = "ApplyNotSupported" + +class AccessReviewInstanceReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This field specifies the type of reviewers for a review. Usually for a review, reviewers are + explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be + chosen dynamically. For example managers review or self review. + """ + + ASSIGNED = "Assigned" + SELF = "Self" + MANAGERS = "Managers" + +class AccessReviewInstanceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This read-only field specifies the status of an access review instance. + """ + + NOT_STARTED = "NotStarted" + IN_PROGRESS = "InProgress" + COMPLETED = "Completed" + APPLIED = "Applied" + INITIALIZING = "Initializing" + APPLYING = "Applying" + COMPLETING = "Completing" + SCHEDULED = "Scheduled" + AUTO_REVIEWING = "AutoReviewing" + AUTO_REVIEWED = "AutoReviewed" + STARTING = "Starting" + +class AccessReviewRecurrencePatternType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The recurrence type : weekly, monthly, etc. + """ + + WEEKLY = "weekly" + ABSOLUTE_MONTHLY = "absoluteMonthly" + +class AccessReviewRecurrenceRangeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The recurrence range type. The possible values are: endDate, noEnd, numbered. + """ + + END_DATE = "endDate" + NO_END = "noEnd" + NUMBERED = "numbered" + +class AccessReviewResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The decision on the approval step. This value is initially set to NotReviewed. Approvers can + take action of Approve/Deny + """ + + APPROVE = "Approve" + DENY = "Deny" + NOT_REVIEWED = "NotReviewed" + DONT_KNOW = "DontKnow" + NOT_NOTIFIED = "NotNotified" + +class AccessReviewReviewerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type : user/servicePrincipal + """ + + USER = "user" + SERVICE_PRINCIPAL = "servicePrincipal" + +class AccessReviewScheduleDefinitionReviewersType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This field specifies the type of reviewers for a review. Usually for a review, reviewers are + explicitly assigned. However, in some cases, the reviewers may not be assigned and instead be + chosen dynamically. For example managers review or self review. + """ + + ASSIGNED = "Assigned" + SELF = "Self" + MANAGERS = "Managers" + +class AccessReviewScheduleDefinitionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This read-only field specifies the status of an accessReview. + """ + + NOT_STARTED = "NotStarted" + IN_PROGRESS = "InProgress" + COMPLETED = "Completed" + APPLIED = "Applied" + INITIALIZING = "Initializing" + APPLYING = "Applying" + COMPLETING = "Completing" + SCHEDULED = "Scheduled" + AUTO_REVIEWING = "AutoReviewing" + AUTO_REVIEWED = "AutoReviewed" + STARTING = "Starting" + +class AccessReviewScopeAssignmentState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The role assignment state eligible/active to review + """ + + ELIGIBLE = "eligible" + ACTIVE = "active" + +class AccessReviewScopePrincipalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The identity type user/servicePrincipal to review + """ + + USER = "user" + GUEST_USER = "guestUser" + SERVICE_PRINCIPAL = "servicePrincipal" + USER_GROUP = "user,group" + REDEEMED_GUEST_USER = "redeemedGuestUser" + +class DecisionResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of resource + """ + + AZURE_ROLE = "azureRole" + +class DecisionTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of decision target : User/ServicePrincipal + """ + + USER = "user" + SERVICE_PRINCIPAL = "servicePrincipal" + +class DefaultDecisionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """This specifies the behavior for the autoReview feature when an access review completes. + """ + + APPROVE = "Approve" + DENY = "Deny" + RECOMMENDATION = "Recommendation" diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..2b932c8542b8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/models/_models_py3.py @@ -0,0 +1,2061 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for 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 datetime +from typing import List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._authorization_management_client_enums import * + + +class AccessReviewContactedReviewer(msrest.serialization.Model): + """Access Review Contacted Reviewer. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review reviewer id. + :vartype id: str + :ivar name: The access review reviewer id. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar user_display_name: The display name of the reviewer. + :vartype user_display_name: str + :ivar user_principal_name: The user principal name of the reviewer. + :vartype user_principal_name: str + :ivar created_date_time: Date Time when the reviewer was contacted. + :vartype created_date_time: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'user_display_name': {'readonly': True}, + 'user_principal_name': {'readonly': True}, + 'created_date_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'user_display_name': {'key': 'properties.userDisplayName', 'type': 'str'}, + 'user_principal_name': {'key': 'properties.userPrincipalName', 'type': 'str'}, + 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AccessReviewContactedReviewer, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.user_display_name = None + self.user_principal_name = None + self.created_date_time = None + + +class AccessReviewContactedReviewerListResult(msrest.serialization.Model): + """List of access review contacted reviewers. + + :ivar value: Access Review Contacted Reviewer. + :vartype value: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AccessReviewContactedReviewer]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AccessReviewContactedReviewer"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Access Review Contacted Reviewer. + :paramtype value: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewer] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(AccessReviewContactedReviewerListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecision(msrest.serialization.Model): + """Access Review. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review decision id. + :vartype id: str + :ivar name: The access review decision name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible + values include: "Approve", "Deny", "NoInfoAvailable". + :vartype recommendation: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. + Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", + "NotReviewed", "DontKnow", "NotNotified". + :vartype decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str + :ivar reviewed_date_time: Date Time when a decision was taken. + :vartype reviewed_date_time: ~datetime.datetime + :ivar apply_result: The outcome of applying the decision. Possible values include: "New", + "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", + "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". + :vartype apply_result: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult + :ivar applied_date_time: The date and time when the review decision was applied. + :vartype applied_date_time: ~datetime.datetime + :ivar principal_id_properties_applied_by_principal_id: The identity id. + :vartype principal_id_properties_applied_by_principal_id: str + :ivar principal_type_properties_applied_by_principal_type: The identity type : + user/servicePrincipal. Possible values include: "user", "servicePrincipal". + :vartype principal_type_properties_applied_by_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType + :ivar principal_name_properties_applied_by_principal_name: The identity display name. + :vartype principal_name_properties_applied_by_principal_name: str + :ivar user_principal_name_properties_applied_by_user_principal_name: The user principal name(if + valid). + :vartype user_principal_name_properties_applied_by_user_principal_name: str + :ivar principal_id_properties_reviewed_by_principal_id: The identity id. + :vartype principal_id_properties_reviewed_by_principal_id: str + :ivar principal_type_properties_reviewed_by_principal_type: The identity type : + user/servicePrincipal. Possible values include: "user", "servicePrincipal". + :vartype principal_type_properties_reviewed_by_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType + :ivar principal_name_properties_reviewed_by_principal_name: The identity display name. + :vartype principal_name_properties_reviewed_by_principal_name: str + :ivar user_principal_name_properties_reviewed_by_user_principal_name: The user principal + name(if valid). + :vartype user_principal_name_properties_reviewed_by_user_principal_name: str + :ivar type_properties_resource_type: The type of resource.Constant filled by server. Possible + values include: "azureRole". + :vartype type_properties_resource_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType + :ivar id_properties_resource_id: The id of resource associated with a decision record. + :vartype id_properties_resource_id: str + :ivar display_name_properties_resource_display_name: The display name of resource associated + with a decision record. + :vartype display_name_properties_resource_display_name: str + :ivar type_properties_principal_type: The type of decision target : + User/ServicePrincipal.Constant filled by server. Possible values include: "user", + "servicePrincipal". + :vartype type_properties_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType + :ivar id_properties_principal_id: The id of principal whose access was reviewed. + :vartype id_properties_principal_id: str + :ivar display_name_properties_principal_display_name: The display name of the user whose access + was reviewed. + :vartype display_name_properties_principal_display_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'recommendation': {'readonly': True}, + 'reviewed_date_time': {'readonly': True}, + 'apply_result': {'readonly': True}, + 'applied_date_time': {'readonly': True}, + 'principal_id_properties_applied_by_principal_id': {'readonly': True}, + 'principal_type_properties_applied_by_principal_type': {'readonly': True}, + 'principal_name_properties_applied_by_principal_name': {'readonly': True}, + 'user_principal_name_properties_applied_by_user_principal_name': {'readonly': True}, + 'principal_id_properties_reviewed_by_principal_id': {'readonly': True}, + 'principal_type_properties_reviewed_by_principal_type': {'readonly': True}, + 'principal_name_properties_reviewed_by_principal_name': {'readonly': True}, + 'user_principal_name_properties_reviewed_by_user_principal_name': {'readonly': True}, + 'id_properties_resource_id': {'readonly': True}, + 'display_name_properties_resource_display_name': {'readonly': True}, + 'id_properties_principal_id': {'readonly': True}, + 'display_name_properties_principal_display_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'recommendation': {'key': 'properties.recommendation', 'type': 'str'}, + 'decision': {'key': 'properties.decision', 'type': 'str'}, + 'justification': {'key': 'properties.justification', 'type': 'str'}, + 'reviewed_date_time': {'key': 'properties.reviewedDateTime', 'type': 'iso-8601'}, + 'apply_result': {'key': 'properties.applyResult', 'type': 'str'}, + 'applied_date_time': {'key': 'properties.appliedDateTime', 'type': 'iso-8601'}, + 'principal_id_properties_applied_by_principal_id': {'key': 'properties.appliedBy.principalId', 'type': 'str'}, + 'principal_type_properties_applied_by_principal_type': {'key': 'properties.appliedBy.principalType', 'type': 'str'}, + 'principal_name_properties_applied_by_principal_name': {'key': 'properties.appliedBy.principalName', 'type': 'str'}, + 'user_principal_name_properties_applied_by_user_principal_name': {'key': 'properties.appliedBy.userPrincipalName', 'type': 'str'}, + 'principal_id_properties_reviewed_by_principal_id': {'key': 'properties.reviewedBy.principalId', 'type': 'str'}, + 'principal_type_properties_reviewed_by_principal_type': {'key': 'properties.reviewedBy.principalType', 'type': 'str'}, + 'principal_name_properties_reviewed_by_principal_name': {'key': 'properties.reviewedBy.principalName', 'type': 'str'}, + 'user_principal_name_properties_reviewed_by_user_principal_name': {'key': 'properties.reviewedBy.userPrincipalName', 'type': 'str'}, + 'type_properties_resource_type': {'key': 'properties.resource.type', 'type': 'str'}, + 'id_properties_resource_id': {'key': 'properties.resource.id', 'type': 'str'}, + 'display_name_properties_resource_display_name': {'key': 'properties.resource.displayName', 'type': 'str'}, + 'type_properties_principal_type': {'key': 'properties.principal.type', 'type': 'str'}, + 'id_properties_principal_id': {'key': 'properties.principal.id', 'type': 'str'}, + 'display_name_properties_principal_display_name': {'key': 'properties.principal.displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + decision: Optional[Union[str, "AccessReviewResult"]] = None, + justification: Optional[str] = None, + **kwargs + ): + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed", "DontKnow", "NotNotified". + :paramtype decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ + super(AccessReviewDecision, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.recommendation = None + self.decision = decision + self.justification = justification + self.reviewed_date_time = None + self.apply_result = None + self.applied_date_time = None + self.principal_id_properties_applied_by_principal_id = None + self.principal_type_properties_applied_by_principal_type = None + self.principal_name_properties_applied_by_principal_name = None + self.user_principal_name_properties_applied_by_user_principal_name = None + self.principal_id_properties_reviewed_by_principal_id = None + self.principal_type_properties_reviewed_by_principal_type = None + self.principal_name_properties_reviewed_by_principal_name = None + self.user_principal_name_properties_reviewed_by_user_principal_name = None + self.type_properties_resource_type = None # type: Optional[str] + self.id_properties_resource_id = None + self.display_name_properties_resource_display_name = None + self.type_properties_principal_type = None # type: Optional[str] + self.id_properties_principal_id = None + self.display_name_properties_principal_display_name = None + + +class AccessReviewDecisionIdentity(msrest.serialization.Model): + """Target of the decision. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: AccessReviewDecisionServicePrincipalIdentity, AccessReviewDecisionUserIdentity. + + 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType + :ivar id: The id of principal whose access was reviewed. + :vartype id: str + :ivar display_name: The display name of the user whose access was reviewed. + :vartype display_name: str + """ + + _validation = { + 'type': {'required': True}, + 'id': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + _subtype_map = { + 'type': {'servicePrincipal': 'AccessReviewDecisionServicePrincipalIdentity', 'user': 'AccessReviewDecisionUserIdentity'} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AccessReviewDecisionIdentity, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.id = None + self.display_name = None + + +class AccessReviewDecisionListResult(msrest.serialization.Model): + """List of access review decisions. + + :ivar value: Access Review Decision list. + :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AccessReviewDecision]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AccessReviewDecision"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Access Review Decision list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(AccessReviewDecisionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewDecisionProperties(msrest.serialization.Model): + """Approval Step. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar recommendation: The feature- generated recommendation shown to the reviewer. Possible + values include: "Approve", "Deny", "NoInfoAvailable". + :vartype recommendation: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessRecommendationType + :ivar decision: The decision on the approval step. This value is initially set to NotReviewed. + Approvers can take action of Approve/Deny. Possible values include: "Approve", "Deny", + "NotReviewed", "DontKnow", "NotNotified". + :vartype decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult + :ivar justification: Justification provided by approvers for their action. + :vartype justification: str + :ivar reviewed_date_time: Date Time when a decision was taken. + :vartype reviewed_date_time: ~datetime.datetime + :ivar apply_result: The outcome of applying the decision. Possible values include: "New", + "Applying", "AppliedSuccessfully", "AppliedWithUnknownFailure", + "AppliedSuccessfullyButObjectNotFound", "ApplyNotSupported". + :vartype apply_result: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewApplyResult + :ivar applied_date_time: The date and time when the review decision was applied. + :vartype applied_date_time: ~datetime.datetime + :ivar principal_id_applied_by_principal_id: The identity id. + :vartype principal_id_applied_by_principal_id: str + :ivar principal_type_applied_by_principal_type: The identity type : user/servicePrincipal. + Possible values include: "user", "servicePrincipal". + :vartype principal_type_applied_by_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType + :ivar principal_name_applied_by_principal_name: The identity display name. + :vartype principal_name_applied_by_principal_name: str + :ivar user_principal_name_applied_by_user_principal_name: The user principal name(if valid). + :vartype user_principal_name_applied_by_user_principal_name: str + :ivar principal_id_reviewed_by_principal_id: The identity id. + :vartype principal_id_reviewed_by_principal_id: str + :ivar principal_type_reviewed_by_principal_type: The identity type : user/servicePrincipal. + Possible values include: "user", "servicePrincipal". + :vartype principal_type_reviewed_by_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType + :ivar principal_name_reviewed_by_principal_name: The identity display name. + :vartype principal_name_reviewed_by_principal_name: str + :ivar user_principal_name_reviewed_by_user_principal_name: The user principal name(if valid). + :vartype user_principal_name_reviewed_by_user_principal_name: str + :ivar type_resource_type: The type of resource.Constant filled by server. Possible values + include: "azureRole". + :vartype type_resource_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType + :ivar id_resource_id: The id of resource associated with a decision record. + :vartype id_resource_id: str + :ivar display_name_resource_display_name: The display name of resource associated with a + decision record. + :vartype display_name_resource_display_name: str + :ivar type_principal_type: The type of decision target : User/ServicePrincipal.Constant filled + by server. Possible values include: "user", "servicePrincipal". + :vartype type_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType + :ivar id_principal_id: The id of principal whose access was reviewed. + :vartype id_principal_id: str + :ivar display_name_principal_display_name: The display name of the user whose access was + reviewed. + :vartype display_name_principal_display_name: str + """ + + _validation = { + 'recommendation': {'readonly': True}, + 'reviewed_date_time': {'readonly': True}, + 'apply_result': {'readonly': True}, + 'applied_date_time': {'readonly': True}, + 'principal_id_applied_by_principal_id': {'readonly': True}, + 'principal_type_applied_by_principal_type': {'readonly': True}, + 'principal_name_applied_by_principal_name': {'readonly': True}, + 'user_principal_name_applied_by_user_principal_name': {'readonly': True}, + 'principal_id_reviewed_by_principal_id': {'readonly': True}, + 'principal_type_reviewed_by_principal_type': {'readonly': True}, + 'principal_name_reviewed_by_principal_name': {'readonly': True}, + 'user_principal_name_reviewed_by_user_principal_name': {'readonly': True}, + 'id_resource_id': {'readonly': True}, + 'display_name_resource_display_name': {'readonly': True}, + 'id_principal_id': {'readonly': True}, + 'display_name_principal_display_name': {'readonly': True}, + } + + _attribute_map = { + 'recommendation': {'key': 'recommendation', 'type': 'str'}, + 'decision': {'key': 'decision', 'type': 'str'}, + 'justification': {'key': 'justification', 'type': 'str'}, + 'reviewed_date_time': {'key': 'reviewedDateTime', 'type': 'iso-8601'}, + 'apply_result': {'key': 'applyResult', 'type': 'str'}, + 'applied_date_time': {'key': 'appliedDateTime', 'type': 'iso-8601'}, + 'principal_id_applied_by_principal_id': {'key': 'appliedBy.principalId', 'type': 'str'}, + 'principal_type_applied_by_principal_type': {'key': 'appliedBy.principalType', 'type': 'str'}, + 'principal_name_applied_by_principal_name': {'key': 'appliedBy.principalName', 'type': 'str'}, + 'user_principal_name_applied_by_user_principal_name': {'key': 'appliedBy.userPrincipalName', 'type': 'str'}, + 'principal_id_reviewed_by_principal_id': {'key': 'reviewedBy.principalId', 'type': 'str'}, + 'principal_type_reviewed_by_principal_type': {'key': 'reviewedBy.principalType', 'type': 'str'}, + 'principal_name_reviewed_by_principal_name': {'key': 'reviewedBy.principalName', 'type': 'str'}, + 'user_principal_name_reviewed_by_user_principal_name': {'key': 'reviewedBy.userPrincipalName', 'type': 'str'}, + 'type_resource_type': {'key': 'resource.type', 'type': 'str'}, + 'id_resource_id': {'key': 'resource.id', 'type': 'str'}, + 'display_name_resource_display_name': {'key': 'resource.displayName', 'type': 'str'}, + 'type_principal_type': {'key': 'principal.type', 'type': 'str'}, + 'id_principal_id': {'key': 'principal.id', 'type': 'str'}, + 'display_name_principal_display_name': {'key': 'principal.displayName', 'type': 'str'}, + } + + def __init__( + self, + *, + decision: Optional[Union[str, "AccessReviewResult"]] = None, + justification: Optional[str] = None, + **kwargs + ): + """ + :keyword decision: The decision on the approval step. This value is initially set to + NotReviewed. Approvers can take action of Approve/Deny. Possible values include: "Approve", + "Deny", "NotReviewed", "DontKnow", "NotNotified". + :paramtype decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewResult + :keyword justification: Justification provided by approvers for their action. + :paramtype justification: str + """ + super(AccessReviewDecisionProperties, self).__init__(**kwargs) + self.recommendation = None + self.decision = decision + self.justification = justification + self.reviewed_date_time = None + self.apply_result = None + self.applied_date_time = None + self.principal_id_applied_by_principal_id = None + self.principal_type_applied_by_principal_type = None + self.principal_name_applied_by_principal_name = None + self.user_principal_name_applied_by_user_principal_name = None + self.principal_id_reviewed_by_principal_id = None + self.principal_type_reviewed_by_principal_type = None + self.principal_name_reviewed_by_principal_name = None + self.user_principal_name_reviewed_by_user_principal_name = None + self.type_resource_type = None # type: Optional[str] + self.id_resource_id = None + self.display_name_resource_display_name = None + self.type_principal_type = None # type: Optional[str] + self.id_principal_id = None + self.display_name_principal_display_name = None + + +class AccessReviewDecisionResource(msrest.serialization.Model): + """Target of the decision. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: . + + 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 type: Required. The type of resource.Constant filled by server. Possible values include: + "azureRole". + :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionResourceType + :ivar id: The id of resource associated with a decision record. + :vartype id: str + :ivar display_name: The display name of resource associated with a decision record. + :vartype display_name: str + """ + + _validation = { + 'type': {'required': True}, + 'id': {'readonly': True}, + 'display_name': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + } + + _subtype_map = { + 'type': {} + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AccessReviewDecisionResource, self).__init__(**kwargs) + self.type = None # type: Optional[str] + self.id = None + self.display_name = None + + +class AccessReviewDecisionServicePrincipalIdentity(AccessReviewDecisionIdentity): + """Service Principal Decision Target. + + 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType + :ivar id: The id of principal whose access was reviewed. + :vartype id: str + :ivar display_name: The display name of the user whose access was reviewed. + :vartype display_name: str + :ivar app_id: The appId for the service principal entity being reviewed. + :vartype app_id: str + """ + + _validation = { + 'type': {'required': True}, + 'id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'app_id': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'app_id': {'key': 'appId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AccessReviewDecisionServicePrincipalIdentity, self).__init__(**kwargs) + self.type = 'servicePrincipal' # type: str + self.app_id = None + + +class AccessReviewDecisionUserIdentity(AccessReviewDecisionIdentity): + """User Decision Target. + + 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 type: Required. The type of decision target : User/ServicePrincipal.Constant filled by + server. Possible values include: "user", "servicePrincipal". + :vartype type: str or ~azure.mgmt.authorization.v2021_07_01_preview.models.DecisionTargetType + :ivar id: The id of principal whose access was reviewed. + :vartype id: str + :ivar display_name: The display name of the user whose access was reviewed. + :vartype display_name: str + :ivar user_principal_name: The user principal name of the user whose access was reviewed. + :vartype user_principal_name: str + """ + + _validation = { + 'type': {'required': True}, + 'id': {'readonly': True}, + 'display_name': {'readonly': True}, + 'user_principal_name': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'user_principal_name': {'key': 'userPrincipalName', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AccessReviewDecisionUserIdentity, self).__init__(**kwargs) + self.type = 'user' # type: str + self.user_principal_name = None + + +class AccessReviewDefaultSettings(msrest.serialization.Model): + """Access Review Default Settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review default settings id. This is only going to be default. + :vartype id: str + :ivar name: The access review default settings name. This is always going to be Access Review + Default Settings. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Possible values include: "Approve", "Deny", "Recommendation". + :vartype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :vartype type_properties_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :vartype type_properties_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'mail_notifications_enabled': {'key': 'properties.mailNotificationsEnabled', 'type': 'bool'}, + 'reminder_notifications_enabled': {'key': 'properties.reminderNotificationsEnabled', 'type': 'bool'}, + 'default_decision_enabled': {'key': 'properties.defaultDecisionEnabled', 'type': 'bool'}, + 'justification_required_on_approval': {'key': 'properties.justificationRequiredOnApproval', 'type': 'bool'}, + 'default_decision': {'key': 'properties.defaultDecision', 'type': 'str'}, + 'auto_apply_decisions_enabled': {'key': 'properties.autoApplyDecisionsEnabled', 'type': 'bool'}, + 'recommendations_enabled': {'key': 'properties.recommendationsEnabled', 'type': 'bool'}, + 'recommendation_look_back_duration': {'key': 'properties.recommendationLookBackDuration', 'type': 'duration'}, + 'instance_duration_in_days': {'key': 'properties.instanceDurationInDays', 'type': 'int'}, + 'type_properties_recurrence_range_type': {'key': 'properties.recurrence.range.type', 'type': 'str'}, + 'number_of_occurrences': {'key': 'properties.recurrence.range.numberOfOccurrences', 'type': 'int'}, + 'start_date': {'key': 'properties.recurrence.range.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'properties.recurrence.range.endDate', 'type': 'iso-8601'}, + 'type_properties_recurrence_pattern_type': {'key': 'properties.recurrence.pattern.type', 'type': 'str'}, + 'interval': {'key': 'properties.recurrence.pattern.interval', 'type': 'int'}, + } + + def __init__( + self, + *, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_properties_recurrence_range_type: Optional[Union[str, "AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_properties_recurrence_pattern_type: Optional[Union[str, "AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs + ): + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_properties_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :paramtype type_properties_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super(AccessReviewDefaultSettings, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_properties_recurrence_range_type = type_properties_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_properties_recurrence_pattern_type = type_properties_recurrence_pattern_type + self.interval = interval + + +class AccessReviewInstance(msrest.serialization.Model): + """Access Review Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review instance id. + :vartype id: str + :ivar name: The access review instance name. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar status: This read-only field specifies the status of an access review instance. Possible + values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :vartype status: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus + :ivar start_date_time: The DateTime when the review instance is scheduled to be start. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The DateTime when the review instance is scheduled to end. + :vartype end_date_time: ~datetime.datetime + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a + review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be + assigned and instead be chosen dynamically. For example managers review or self review. + Possible values include: "Assigned", "Self", "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'reviewers_type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, + 'end_date_time': {'key': 'properties.endDateTime', 'type': 'iso-8601'}, + 'reviewers': {'key': 'properties.reviewers', 'type': '[AccessReviewReviewer]'}, + 'backup_reviewers': {'key': 'properties.backupReviewers', 'type': '[AccessReviewReviewer]'}, + 'reviewers_type': {'key': 'properties.reviewersType', 'type': 'str'}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + reviewers: Optional[List["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, + **kwargs + ): + """ + :keyword start_date_time: The DateTime when the review instance is scheduled to be start. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The DateTime when the review instance is scheduled to end. + :paramtype end_date_time: ~datetime.datetime + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + """ + super(AccessReviewInstance, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.status = None + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type = None + + +class AccessReviewInstanceListResult(msrest.serialization.Model): + """List of Access Review Instances. + + :ivar value: Access Review Instance list. + :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AccessReviewInstance]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AccessReviewInstance"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Access Review Instance list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(AccessReviewInstanceListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewInstanceProperties(msrest.serialization.Model): + """Access Review Instance properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: This read-only field specifies the status of an access review instance. Possible + values include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :vartype status: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceStatus + :ivar start_date_time: The DateTime when the review instance is scheduled to be start. + :vartype start_date_time: ~datetime.datetime + :ivar end_date_time: The DateTime when the review instance is scheduled to end. + :vartype end_date_time: ~datetime.datetime + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a + review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be + assigned and instead be chosen dynamically. For example managers review or self review. + Possible values include: "Assigned", "Self", "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceReviewersType + """ + + _validation = { + 'status': {'readonly': True}, + 'reviewers_type': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'end_date_time': {'key': 'endDateTime', 'type': 'iso-8601'}, + 'reviewers': {'key': 'reviewers', 'type': '[AccessReviewReviewer]'}, + 'backup_reviewers': {'key': 'backupReviewers', 'type': '[AccessReviewReviewer]'}, + 'reviewers_type': {'key': 'reviewersType', 'type': 'str'}, + } + + def __init__( + self, + *, + start_date_time: Optional[datetime.datetime] = None, + end_date_time: Optional[datetime.datetime] = None, + reviewers: Optional[List["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, + **kwargs + ): + """ + :keyword start_date_time: The DateTime when the review instance is scheduled to be start. + :paramtype start_date_time: ~datetime.datetime + :keyword end_date_time: The DateTime when the review instance is scheduled to end. + :paramtype end_date_time: ~datetime.datetime + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + """ + super(AccessReviewInstanceProperties, self).__init__(**kwargs) + self.status = None + self.start_date_time = start_date_time + self.end_date_time = end_date_time + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type = None + + +class AccessReviewReviewer(msrest.serialization.Model): + """Descriptor for what needs to be reviewed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The id of the reviewer(user/servicePrincipal). + :vartype principal_id: str + :ivar principal_type: The identity type : user/servicePrincipal. Possible values include: + "user", "servicePrincipal". + :vartype principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewerType + """ + + _validation = { + 'principal_type': {'readonly': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'principal_type': {'key': 'principalType', 'type': 'str'}, + } + + def __init__( + self, + *, + principal_id: Optional[str] = None, + **kwargs + ): + """ + :keyword principal_id: The id of the reviewer(user/servicePrincipal). + :paramtype principal_id: str + """ + super(AccessReviewReviewer, self).__init__(**kwargs) + self.principal_id = principal_id + self.principal_type = None + + +class AccessReviewScheduleDefinition(msrest.serialization.Model): + """Access Review Schedule Definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The access review schedule definition id. + :vartype id: str + :ivar name: The access review schedule definition unique id. + :vartype name: str + :ivar type: The resource type. + :vartype type: str + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str + :ivar status: This read-only field specifies the status of an accessReview. Possible values + include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :vartype status: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a + review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be + assigned and instead be chosen dynamically. For example managers review or self review. + Possible values include: "Assigned", "Self", "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] + :ivar resource_id: ResourceId in which this review is getting created. + :vartype resource_id: str + :ivar role_definition_id: This is used to indicate the role being reviewed. + :vartype role_definition_id: str + :ivar principal_type_properties_scope_principal_type: The identity type user/servicePrincipal + to review. Possible values include: "user", "guestUser", "servicePrincipal", "user,group", + "redeemedGuestUser". + :vartype principal_type_properties_scope_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType + :ivar assignment_state: The role assignment state eligible/active to review. Possible values + include: "eligible", "active". + :vartype assignment_state: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :vartype inactive_duration: ~datetime.timedelta + :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. + :vartype expand_nested_memberships: bool + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Possible values include: "Approve", "Deny", "Recommendation". + :vartype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_properties_settings_recurrence_range_type: The recurrence range type. The possible + values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :vartype type_properties_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, + etc. Possible values include: "weekly", "absoluteMonthly". + :vartype type_properties_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + :ivar principal_id: The identity id. + :vartype principal_id: str + :ivar principal_type_properties_created_by_principal_type: The identity type : + user/servicePrincipal. Possible values include: "user", "servicePrincipal". + :vartype principal_type_properties_created_by_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType + :ivar principal_name: The identity display name. + :vartype principal_name: str + :ivar user_principal_name: The user principal name(if valid). + :vartype user_principal_name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'reviewers_type': {'readonly': True}, + 'resource_id': {'readonly': True}, + 'role_definition_id': {'readonly': True}, + 'principal_type_properties_scope_principal_type': {'readonly': True}, + 'assignment_state': {'readonly': True}, + 'principal_id': {'readonly': True}, + 'principal_type_properties_created_by_principal_type': {'readonly': True}, + 'principal_name': {'readonly': True}, + 'user_principal_name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'description_for_admins': {'key': 'properties.descriptionForAdmins', 'type': 'str'}, + 'description_for_reviewers': {'key': 'properties.descriptionForReviewers', 'type': 'str'}, + 'reviewers': {'key': 'properties.reviewers', 'type': '[AccessReviewReviewer]'}, + 'backup_reviewers': {'key': 'properties.backupReviewers', 'type': '[AccessReviewReviewer]'}, + 'reviewers_type': {'key': 'properties.reviewersType', 'type': 'str'}, + 'instances': {'key': 'properties.instances', 'type': '[AccessReviewInstance]'}, + 'resource_id': {'key': 'properties.scope.resourceId', 'type': 'str'}, + 'role_definition_id': {'key': 'properties.scope.roleDefinitionId', 'type': 'str'}, + 'principal_type_properties_scope_principal_type': {'key': 'properties.scope.principalType', 'type': 'str'}, + 'assignment_state': {'key': 'properties.scope.assignmentState', 'type': 'str'}, + 'inactive_duration': {'key': 'properties.scope.inactiveDuration', 'type': 'duration'}, + 'expand_nested_memberships': {'key': 'properties.scope.expandNestedMemberships', 'type': 'bool'}, + 'mail_notifications_enabled': {'key': 'properties.settings.mailNotificationsEnabled', 'type': 'bool'}, + 'reminder_notifications_enabled': {'key': 'properties.settings.reminderNotificationsEnabled', 'type': 'bool'}, + 'default_decision_enabled': {'key': 'properties.settings.defaultDecisionEnabled', 'type': 'bool'}, + 'justification_required_on_approval': {'key': 'properties.settings.justificationRequiredOnApproval', 'type': 'bool'}, + 'default_decision': {'key': 'properties.settings.defaultDecision', 'type': 'str'}, + 'auto_apply_decisions_enabled': {'key': 'properties.settings.autoApplyDecisionsEnabled', 'type': 'bool'}, + 'recommendations_enabled': {'key': 'properties.settings.recommendationsEnabled', 'type': 'bool'}, + 'recommendation_look_back_duration': {'key': 'properties.settings.recommendationLookBackDuration', 'type': 'duration'}, + 'instance_duration_in_days': {'key': 'properties.settings.instanceDurationInDays', 'type': 'int'}, + 'type_properties_settings_recurrence_range_type': {'key': 'properties.settings.recurrence.range.type', 'type': 'str'}, + 'number_of_occurrences': {'key': 'properties.settings.recurrence.range.numberOfOccurrences', 'type': 'int'}, + 'start_date': {'key': 'properties.settings.recurrence.range.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'properties.settings.recurrence.range.endDate', 'type': 'iso-8601'}, + 'type_properties_settings_recurrence_pattern_type': {'key': 'properties.settings.recurrence.pattern.type', 'type': 'str'}, + 'interval': {'key': 'properties.settings.recurrence.pattern.interval', 'type': 'int'}, + 'principal_id': {'key': 'properties.createdBy.principalId', 'type': 'str'}, + 'principal_type_properties_created_by_principal_type': {'key': 'properties.createdBy.principalType', 'type': 'str'}, + 'principal_name': {'key': 'properties.createdBy.principalName', 'type': 'str'}, + 'user_principal_name': {'key': 'properties.createdBy.userPrincipalName', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description_for_admins: Optional[str] = None, + description_for_reviewers: Optional[str] = None, + reviewers: Optional[List["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, + instances: Optional[List["AccessReviewInstance"]] = None, + inactive_duration: Optional[datetime.timedelta] = None, + expand_nested_memberships: Optional[bool] = None, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_properties_settings_recurrence_range_type: Optional[Union[str, "AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_properties_settings_recurrence_pattern_type: Optional[Union[str, "AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs + ): + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or + not. + :paramtype expand_nested_memberships: bool + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_properties_settings_recurrence_range_type: The recurrence range type. The + possible values are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", + "numbered". + :paramtype type_properties_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_properties_settings_recurrence_pattern_type: The recurrence type : weekly, + monthly, etc. Possible values include: "weekly", "absoluteMonthly". + :paramtype type_properties_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super(AccessReviewScheduleDefinition, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.display_name = display_name + self.status = None + self.description_for_admins = description_for_admins + self.description_for_reviewers = description_for_reviewers + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type = None + self.instances = instances + self.resource_id = None + self.role_definition_id = None + self.principal_type_properties_scope_principal_type = None + self.assignment_state = None + self.inactive_duration = inactive_duration + self.expand_nested_memberships = expand_nested_memberships + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_properties_settings_recurrence_range_type = type_properties_settings_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_properties_settings_recurrence_pattern_type = type_properties_settings_recurrence_pattern_type + self.interval = interval + self.principal_id = None + self.principal_type_properties_created_by_principal_type = None + self.principal_name = None + self.user_principal_name = None + + +class AccessReviewScheduleDefinitionListResult(msrest.serialization.Model): + """List of Access Review Schedule Definitions. + + :ivar value: Access Review Schedule Definition list. + :vartype value: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[AccessReviewScheduleDefinition]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["AccessReviewScheduleDefinition"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Access Review Schedule Definition list. + :paramtype value: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ + super(AccessReviewScheduleDefinitionListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AccessReviewScheduleDefinitionProperties(msrest.serialization.Model): + """Access Review. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar display_name: The display name for the schedule definition. + :vartype display_name: str + :ivar status: This read-only field specifies the status of an accessReview. Possible values + include: "NotStarted", "InProgress", "Completed", "Applied", "Initializing", "Applying", + "Completing", "Scheduled", "AutoReviewing", "AutoReviewed", "Starting". + :vartype status: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionStatus + :ivar description_for_admins: The description provided by the access review creator and visible + to admins. + :vartype description_for_admins: str + :ivar description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :vartype description_for_reviewers: str + :ivar reviewers: This is the collection of reviewers. + :vartype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar backup_reviewers: This is the collection of backup reviewers. + :vartype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :ivar reviewers_type: This field specifies the type of reviewers for a review. Usually for a + review, reviewers are explicitly assigned. However, in some cases, the reviewers may not be + assigned and instead be chosen dynamically. For example managers review or self review. + Possible values include: "Assigned", "Self", "Managers". + :vartype reviewers_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionReviewersType + :ivar instances: This is the collection of instances returned when one does an expand on it. + :vartype instances: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] + :ivar resource_id: ResourceId in which this review is getting created. + :vartype resource_id: str + :ivar role_definition_id: This is used to indicate the role being reviewed. + :vartype role_definition_id: str + :ivar principal_type_scope_principal_type: The identity type user/servicePrincipal to review. + Possible values include: "user", "guestUser", "servicePrincipal", "user,group", + "redeemedGuestUser". + :vartype principal_type_scope_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopePrincipalType + :ivar assignment_state: The role assignment state eligible/active to review. Possible values + include: "eligible", "active". + :vartype assignment_state: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScopeAssignmentState + :ivar inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :vartype inactive_duration: ~datetime.timedelta + :ivar expand_nested_memberships: Flag to indicate whether to expand nested memberships or not. + :vartype expand_nested_memberships: bool + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Possible values include: "Approve", "Deny", "Recommendation". + :vartype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_settings_recurrence_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :vartype type_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :vartype type_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + :ivar principal_id: The identity id. + :vartype principal_id: str + :ivar principal_type_created_by_principal_type: The identity type : user/servicePrincipal. + Possible values include: "user", "servicePrincipal". + :vartype principal_type_created_by_principal_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewActorIdentityType + :ivar principal_name: The identity display name. + :vartype principal_name: str + :ivar user_principal_name: The user principal name(if valid). + :vartype user_principal_name: str + """ + + _validation = { + 'status': {'readonly': True}, + 'reviewers_type': {'readonly': True}, + 'resource_id': {'readonly': True}, + 'role_definition_id': {'readonly': True}, + 'principal_type_scope_principal_type': {'readonly': True}, + 'assignment_state': {'readonly': True}, + 'principal_id': {'readonly': True}, + 'principal_type_created_by_principal_type': {'readonly': True}, + 'principal_name': {'readonly': True}, + 'user_principal_name': {'readonly': True}, + } + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'description_for_admins': {'key': 'descriptionForAdmins', 'type': 'str'}, + 'description_for_reviewers': {'key': 'descriptionForReviewers', 'type': 'str'}, + 'reviewers': {'key': 'reviewers', 'type': '[AccessReviewReviewer]'}, + 'backup_reviewers': {'key': 'backupReviewers', 'type': '[AccessReviewReviewer]'}, + 'reviewers_type': {'key': 'reviewersType', 'type': 'str'}, + 'instances': {'key': 'instances', 'type': '[AccessReviewInstance]'}, + 'resource_id': {'key': 'scope.resourceId', 'type': 'str'}, + 'role_definition_id': {'key': 'scope.roleDefinitionId', 'type': 'str'}, + 'principal_type_scope_principal_type': {'key': 'scope.principalType', 'type': 'str'}, + 'assignment_state': {'key': 'scope.assignmentState', 'type': 'str'}, + 'inactive_duration': {'key': 'scope.inactiveDuration', 'type': 'duration'}, + 'expand_nested_memberships': {'key': 'scope.expandNestedMemberships', 'type': 'bool'}, + 'mail_notifications_enabled': {'key': 'settings.mailNotificationsEnabled', 'type': 'bool'}, + 'reminder_notifications_enabled': {'key': 'settings.reminderNotificationsEnabled', 'type': 'bool'}, + 'default_decision_enabled': {'key': 'settings.defaultDecisionEnabled', 'type': 'bool'}, + 'justification_required_on_approval': {'key': 'settings.justificationRequiredOnApproval', 'type': 'bool'}, + 'default_decision': {'key': 'settings.defaultDecision', 'type': 'str'}, + 'auto_apply_decisions_enabled': {'key': 'settings.autoApplyDecisionsEnabled', 'type': 'bool'}, + 'recommendations_enabled': {'key': 'settings.recommendationsEnabled', 'type': 'bool'}, + 'recommendation_look_back_duration': {'key': 'settings.recommendationLookBackDuration', 'type': 'duration'}, + 'instance_duration_in_days': {'key': 'settings.instanceDurationInDays', 'type': 'int'}, + 'type_settings_recurrence_range_type': {'key': 'settings.recurrence.range.type', 'type': 'str'}, + 'number_of_occurrences': {'key': 'settings.recurrence.range.numberOfOccurrences', 'type': 'int'}, + 'start_date': {'key': 'settings.recurrence.range.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'settings.recurrence.range.endDate', 'type': 'iso-8601'}, + 'type_settings_recurrence_pattern_type': {'key': 'settings.recurrence.pattern.type', 'type': 'str'}, + 'interval': {'key': 'settings.recurrence.pattern.interval', 'type': 'int'}, + 'principal_id': {'key': 'createdBy.principalId', 'type': 'str'}, + 'principal_type_created_by_principal_type': {'key': 'createdBy.principalType', 'type': 'str'}, + 'principal_name': {'key': 'createdBy.principalName', 'type': 'str'}, + 'user_principal_name': {'key': 'createdBy.userPrincipalName', 'type': 'str'}, + } + + def __init__( + self, + *, + display_name: Optional[str] = None, + description_for_admins: Optional[str] = None, + description_for_reviewers: Optional[str] = None, + reviewers: Optional[List["AccessReviewReviewer"]] = None, + backup_reviewers: Optional[List["AccessReviewReviewer"]] = None, + instances: Optional[List["AccessReviewInstance"]] = None, + inactive_duration: Optional[datetime.timedelta] = None, + expand_nested_memberships: Optional[bool] = None, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_settings_recurrence_range_type: Optional[Union[str, "AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_settings_recurrence_pattern_type: Optional[Union[str, "AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs + ): + """ + :keyword display_name: The display name for the schedule definition. + :paramtype display_name: str + :keyword description_for_admins: The description provided by the access review creator and + visible to admins. + :paramtype description_for_admins: str + :keyword description_for_reviewers: The description provided by the access review creator to be + shown to reviewers. + :paramtype description_for_reviewers: str + :keyword reviewers: This is the collection of reviewers. + :paramtype reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :keyword backup_reviewers: This is the collection of backup reviewers. + :paramtype backup_reviewers: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewReviewer] + :keyword instances: This is the collection of instances returned when one does an expand on it. + :paramtype instances: + list[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance] + :keyword inactive_duration: Duration users are inactive for. The value should be in ISO 8601 + format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can be used to convert + TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, minutes, + seconds)). + :paramtype inactive_duration: ~datetime.timedelta + :keyword expand_nested_memberships: Flag to indicate whether to expand nested memberships or + not. + :paramtype expand_nested_memberships: bool + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_settings_recurrence_range_type: The recurrence range type. The possible values + are: endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_settings_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_settings_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. + Possible values include: "weekly", "absoluteMonthly". + :paramtype type_settings_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super(AccessReviewScheduleDefinitionProperties, self).__init__(**kwargs) + self.display_name = display_name + self.status = None + self.description_for_admins = description_for_admins + self.description_for_reviewers = description_for_reviewers + self.reviewers = reviewers + self.backup_reviewers = backup_reviewers + self.reviewers_type = None + self.instances = instances + self.resource_id = None + self.role_definition_id = None + self.principal_type_scope_principal_type = None + self.assignment_state = None + self.inactive_duration = inactive_duration + self.expand_nested_memberships = expand_nested_memberships + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_settings_recurrence_range_type = type_settings_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_settings_recurrence_pattern_type = type_settings_recurrence_pattern_type + self.interval = interval + self.principal_id = None + self.principal_type_created_by_principal_type = None + self.principal_name = None + self.user_principal_name = None + + +class AccessReviewScheduleSettings(msrest.serialization.Model): + """Settings of an Access Review. + + :ivar mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and the + review creator is enabled. + :vartype mail_notifications_enabled: bool + :ivar reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :vartype reminder_notifications_enabled: bool + :ivar default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :vartype default_decision_enabled: bool + :ivar justification_required_on_approval: Flag to indicate whether the reviewer is required to + pass justification when recording a decision. + :vartype justification_required_on_approval: bool + :ivar default_decision: This specifies the behavior for the autoReview feature when an access + review completes. Possible values include: "Approve", "Deny", "Recommendation". + :vartype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :ivar auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :vartype auto_apply_decisions_enabled: bool + :ivar recommendations_enabled: Flag to indicate whether showing recommendations to reviewers is + enabled. + :vartype recommendations_enabled: bool + :ivar recommendation_look_back_duration: Recommendations for access reviews are calculated by + looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :vartype recommendation_look_back_duration: ~datetime.timedelta + :ivar instance_duration_in_days: The duration in days for an instance. + :vartype instance_duration_in_days: int + :ivar type_recurrence_range_type: The recurrence range type. The possible values are: endDate, + noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :vartype type_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :ivar number_of_occurrences: The number of times to repeat the access review. Required and must + be positive if type is numbered. + :vartype number_of_occurrences: int + :ivar start_date: The DateTime when the review is scheduled to be start. This could be a date + in the future. Required on create. + :vartype start_date: ~datetime.datetime + :ivar end_date: The DateTime when the review is scheduled to end. Required if type is endDate. + :vartype end_date: ~datetime.datetime + :ivar type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible values + include: "weekly", "absoluteMonthly". + :vartype type_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :ivar interval: The interval for recurrence. For a quarterly review, the interval is 3 for type + : absoluteMonthly. + :vartype interval: int + """ + + _attribute_map = { + 'mail_notifications_enabled': {'key': 'mailNotificationsEnabled', 'type': 'bool'}, + 'reminder_notifications_enabled': {'key': 'reminderNotificationsEnabled', 'type': 'bool'}, + 'default_decision_enabled': {'key': 'defaultDecisionEnabled', 'type': 'bool'}, + 'justification_required_on_approval': {'key': 'justificationRequiredOnApproval', 'type': 'bool'}, + 'default_decision': {'key': 'defaultDecision', 'type': 'str'}, + 'auto_apply_decisions_enabled': {'key': 'autoApplyDecisionsEnabled', 'type': 'bool'}, + 'recommendations_enabled': {'key': 'recommendationsEnabled', 'type': 'bool'}, + 'recommendation_look_back_duration': {'key': 'recommendationLookBackDuration', 'type': 'duration'}, + 'instance_duration_in_days': {'key': 'instanceDurationInDays', 'type': 'int'}, + 'type_recurrence_range_type': {'key': 'recurrence.range.type', 'type': 'str'}, + 'number_of_occurrences': {'key': 'recurrence.range.numberOfOccurrences', 'type': 'int'}, + 'start_date': {'key': 'recurrence.range.startDate', 'type': 'iso-8601'}, + 'end_date': {'key': 'recurrence.range.endDate', 'type': 'iso-8601'}, + 'type_recurrence_pattern_type': {'key': 'recurrence.pattern.type', 'type': 'str'}, + 'interval': {'key': 'recurrence.pattern.interval', 'type': 'int'}, + } + + def __init__( + self, + *, + mail_notifications_enabled: Optional[bool] = None, + reminder_notifications_enabled: Optional[bool] = None, + default_decision_enabled: Optional[bool] = None, + justification_required_on_approval: Optional[bool] = None, + default_decision: Optional[Union[str, "DefaultDecisionType"]] = None, + auto_apply_decisions_enabled: Optional[bool] = None, + recommendations_enabled: Optional[bool] = None, + recommendation_look_back_duration: Optional[datetime.timedelta] = None, + instance_duration_in_days: Optional[int] = None, + type_recurrence_range_type: Optional[Union[str, "AccessReviewRecurrenceRangeType"]] = None, + number_of_occurrences: Optional[int] = None, + start_date: Optional[datetime.datetime] = None, + end_date: Optional[datetime.datetime] = None, + type_recurrence_pattern_type: Optional[Union[str, "AccessReviewRecurrencePatternType"]] = None, + interval: Optional[int] = None, + **kwargs + ): + """ + :keyword mail_notifications_enabled: Flag to indicate whether sending mails to reviewers and + the review creator is enabled. + :paramtype mail_notifications_enabled: bool + :keyword reminder_notifications_enabled: Flag to indicate whether sending reminder emails to + reviewers are enabled. + :paramtype reminder_notifications_enabled: bool + :keyword default_decision_enabled: Flag to indicate whether reviewers are required to provide a + justification when reviewing access. + :paramtype default_decision_enabled: bool + :keyword justification_required_on_approval: Flag to indicate whether the reviewer is required + to pass justification when recording a decision. + :paramtype justification_required_on_approval: bool + :keyword default_decision: This specifies the behavior for the autoReview feature when an + access review completes. Possible values include: "Approve", "Deny", "Recommendation". + :paramtype default_decision: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.DefaultDecisionType + :keyword auto_apply_decisions_enabled: Flag to indicate whether auto-apply capability, to + automatically change the target object access resource, is enabled. If not enabled, a user + must, after the review completes, apply the access review. + :paramtype auto_apply_decisions_enabled: bool + :keyword recommendations_enabled: Flag to indicate whether showing recommendations to reviewers + is enabled. + :paramtype recommendations_enabled: bool + :keyword recommendation_look_back_duration: Recommendations for access reviews are calculated + by looking back at 30 days of data(w.r.t the start date of the review) by default. However, in + some scenarios, customers want to change how far back to look at and want to configure 60 days, + 90 days, etc. instead. This setting allows customers to configure this duration. The value + should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations).This code can + be used to convert TimeSpan to a valid interval string: XmlConvert.ToString(new TimeSpan(hours, + minutes, seconds)). + :paramtype recommendation_look_back_duration: ~datetime.timedelta + :keyword instance_duration_in_days: The duration in days for an instance. + :paramtype instance_duration_in_days: int + :keyword type_recurrence_range_type: The recurrence range type. The possible values are: + endDate, noEnd, numbered. Possible values include: "endDate", "noEnd", "numbered". + :paramtype type_recurrence_range_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrenceRangeType + :keyword number_of_occurrences: The number of times to repeat the access review. Required and + must be positive if type is numbered. + :paramtype number_of_occurrences: int + :keyword start_date: The DateTime when the review is scheduled to be start. This could be a + date in the future. Required on create. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The DateTime when the review is scheduled to end. Required if type is + endDate. + :paramtype end_date: ~datetime.datetime + :keyword type_recurrence_pattern_type: The recurrence type : weekly, monthly, etc. Possible + values include: "weekly", "absoluteMonthly". + :paramtype type_recurrence_pattern_type: str or + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewRecurrencePatternType + :keyword interval: The interval for recurrence. For a quarterly review, the interval is 3 for + type : absoluteMonthly. + :paramtype interval: int + """ + super(AccessReviewScheduleSettings, self).__init__(**kwargs) + self.mail_notifications_enabled = mail_notifications_enabled + self.reminder_notifications_enabled = reminder_notifications_enabled + self.default_decision_enabled = default_decision_enabled + self.justification_required_on_approval = justification_required_on_approval + self.default_decision = default_decision + self.auto_apply_decisions_enabled = auto_apply_decisions_enabled + self.recommendations_enabled = recommendations_enabled + self.recommendation_look_back_duration = recommendation_look_back_duration + self.instance_duration_in_days = instance_duration_in_days + self.type_recurrence_range_type = type_recurrence_range_type + self.number_of_occurrences = number_of_occurrences + self.start_date = start_date + self.end_date = end_date + self.type_recurrence_pattern_type = type_recurrence_pattern_type + self.interval = interval + + +class ErrorDefinition(msrest.serialization.Model): + """Error description and code explaining why an operation failed. + + :ivar error: Error of the list gateway status. + :vartype error: ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinitionProperties'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDefinitionProperties"] = None, + **kwargs + ): + """ + :keyword error: Error of the list gateway status. + :paramtype error: + ~azure.mgmt.authorization.v2021_07_01_preview.models.ErrorDefinitionProperties + """ + super(ErrorDefinition, self).__init__(**kwargs) + self.error = error + + +class ErrorDefinitionProperties(msrest.serialization.Model): + """Error description and code explaining why an operation failed. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar message: Description of the error. + :vartype message: str + :ivar code: Error code of list gateway. + :vartype code: str + """ + + _validation = { + 'message': {'readonly': True}, + } + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'code': {'key': 'code', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + **kwargs + ): + """ + :keyword code: Error code of list gateway. + :paramtype code: str + """ + super(ErrorDefinitionProperties, self).__init__(**kwargs) + self.message = None + self.code = code + + +class Operation(msrest.serialization.Model): + """The definition of a Microsoft.Authorization operation. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Display of the operation. + :vartype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay + :ivar origin: Origin of the operation. + :vartype origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Display of the operation. + :paramtype display: ~azure.mgmt.authorization.v2021_07_01_preview.models.OperationDisplay + :keyword origin: Origin of the operation. + :paramtype origin: str + """ + super(Operation, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + self.origin = origin + + +class OperationDisplay(msrest.serialization.Model): + """The display information for a Microsoft.Authorization operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The resource provider name: Microsoft.Authorization. + :vartype provider: str + :ivar resource: The resource on which the operation is performed. + :vartype resource: str + :ivar operation: The operation that users can perform. + :vartype operation: str + :ivar description: The description for the operation. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """The result of a request to list Microsoft.Authorization operations. + + :ivar value: The collection value. + :vartype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] + :ivar next_link: The URI that can be used to request the next set of paged results. + :vartype 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 + ): + """ + :keyword value: The collection value. + :paramtype value: list[~azure.mgmt.authorization.v2021_07_01_preview.models.Operation] + :keyword next_link: The URI that can be used to request the next set of paged results. + :paramtype next_link: str + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py new file mode 100644 index 000000000000..92ce9ac76bc5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/__init__.py @@ -0,0 +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. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._access_review_schedule_definitions_operations import AccessReviewScheduleDefinitionsOperations +from ._access_review_instances_operations import AccessReviewInstancesOperations +from ._access_review_instance_operations import AccessReviewInstanceOperations +from ._access_review_instance_decisions_operations import AccessReviewInstanceDecisionsOperations +from ._access_review_instance_contacted_reviewers_operations import AccessReviewInstanceContactedReviewersOperations +from ._access_review_default_settings_operations import AccessReviewDefaultSettingsOperations +from ._access_review_schedule_definitions_assigned_for_my_approval_operations import AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations +from ._access_review_instances_assigned_for_my_approval_operations import AccessReviewInstancesAssignedForMyApprovalOperations +from ._access_review_instance_my_decisions_operations import AccessReviewInstanceMyDecisionsOperations +from ._tenant_level_access_review_instance_contacted_reviewers_operations import TenantLevelAccessReviewInstanceContactedReviewersOperations + +__all__ = [ + 'Operations', + 'AccessReviewScheduleDefinitionsOperations', + 'AccessReviewInstancesOperations', + 'AccessReviewInstanceOperations', + 'AccessReviewInstanceDecisionsOperations', + 'AccessReviewInstanceContactedReviewersOperations', + 'AccessReviewDefaultSettingsOperations', + 'AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations', + 'AccessReviewInstancesAssignedForMyApprovalOperations', + 'AccessReviewInstanceMyDecisionsOperations', + 'TenantLevelAccessReviewInstanceContactedReviewersOperations', +] diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py new file mode 100644 index 000000000000..91e58bba1eea --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_default_settings_operations.py @@ -0,0 +1,230 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_put_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class AccessReviewDefaultSettingsOperations(object): + """AccessReviewDefaultSettingsOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def get( + self, + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": + """Get access review default settings for the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDefaultSettings, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + + + @distributed_trace + def put( + self, + properties: "_models.AccessReviewScheduleSettings", + **kwargs: Any + ) -> "_models.AccessReviewDefaultSettings": + """Get access review default settings for the subscription. + + :param properties: Access review schedule settings. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleSettings + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDefaultSettings, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDefaultSettings + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDefaultSettings"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleSettings') + + request = build_put_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDefaultSettings', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleSettings/default"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..d228533af253 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,168 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AccessReviewInstanceContactedReviewersOperations(object): + """AccessReviewInstanceContactedReviewersOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable["_models.AccessReviewContactedReviewerListResult"]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py new file mode 100644 index 000000000000..0153c18a0488 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_decisions_operations.py @@ -0,0 +1,180 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AccessReviewInstanceDecisionsOperations(object): + """AccessReviewInstanceDecisionsOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewDecisionListResult"]: + """Get access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py new file mode 100644 index 000000000000..7a3ddea660a6 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_my_decisions_operations.py @@ -0,0 +1,389 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "decisionId": _SERIALIZER.url("decision_id", decision_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_patch_request( + schedule_definition_id: str, + id: str, + decision_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "decisionId": _SERIALIZER.url("decision_id", decision_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class AccessReviewInstanceMyDecisionsOperations(object): + """AccessReviewInstanceMyDecisionsOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewDecisionListResult"]: + """Get my access review instance decisions. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewDecisionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecisionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewDecisionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + **kwargs: Any + ) -> "_models.AccessReviewDecision": + """Get my single access review instance decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDecision, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDecision', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + + + @distributed_trace + def patch( + self, + schedule_definition_id: str, + id: str, + decision_id: str, + properties: "_models.AccessReviewDecisionProperties", + **kwargs: Any + ) -> "_models.AccessReviewDecision": + """Record a decision. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param decision_id: The id of the decision record. + :type decision_id: str + :param properties: Access review decision properties to patch. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecisionProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewDecision, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewDecision + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewDecision"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewDecisionProperties') + + request = build_patch_request( + schedule_definition_id=schedule_definition_id, + id=id, + decision_id=decision_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.patch.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewDecision', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/decisions/{decisionId}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py new file mode 100644 index 000000000000..129cf33cf163 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instance_operations.py @@ -0,0 +1,499 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_stop_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_reset_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_apply_decisions_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_send_reminders_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_accept_recommendations_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AccessReviewInstanceOperations(object): + """AccessReviewInstanceOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to stop an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/stop"} # type: ignore + + + @distributed_trace + def reset_decisions( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to reset all decisions for an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_reset_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.reset_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + reset_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/resetDecisions"} # type: ignore + + + @distributed_trace + def apply_decisions( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to apply all decisions for an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_apply_decisions_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.apply_decisions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + apply_decisions.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/applyDecisions"} # type: ignore + + + @distributed_trace + def send_reminders( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to send reminders for an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_send_reminders_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.send_reminders.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + send_reminders.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/sendReminders"} # type: ignore + + + @distributed_trace + def accept_recommendations( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> None: + """An action to accept recommendations for decision in an access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_accept_recommendations_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.accept_recommendations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + accept_recommendations.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/acceptRecommendations"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..549237b24fad --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_assigned_for_my_approval_operations.py @@ -0,0 +1,261 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AccessReviewInstancesAssignedForMyApprovalOperations(object): + """AccessReviewInstancesAssignedForMyApprovalOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewInstanceListResult"]: + """Get access review instances assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + + @distributed_trace + def get_by_id( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": + """Get single access review instance assigned for my approval. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py new file mode 100644 index 000000000000..6bcaec2ad7f5 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_instances_operations.py @@ -0,0 +1,380 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_request( + schedule_definition_id: str, + id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + +class AccessReviewInstancesOperations(object): + """AccessReviewInstancesOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + schedule_definition_id: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewInstanceListResult"]: + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewInstanceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstanceListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewInstanceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances"} # type: ignore + + @distributed_trace + def get_by_id( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> "_models.AccessReviewInstance": + """Get access review instances. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + + + @distributed_trace + def create( + self, + schedule_definition_id: str, + id: str, + properties: "_models.AccessReviewInstanceProperties", + **kwargs: Any + ) -> "_models.AccessReviewInstance": + """Update access review instance. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :param properties: Access review instance properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstanceProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewInstance, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewInstance + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewInstance"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewInstanceProperties') + + request = build_create_request( + schedule_definition_id=schedule_definition_id, + id=id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewInstance', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py new file mode 100644 index 000000000000..2a751a5adf4d --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_assigned_for_my_approval_operations.py @@ -0,0 +1,158 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations(object): + """AccessReviewScheduleDefinitionsAssignedForMyApprovalOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"]: + """Get access review instances assigned for my approval. + + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py new file mode 100644 index 000000000000..ed89601471ec --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_access_review_schedule_definitions_operations.py @@ -0,0 +1,531 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str', skip_quote=True) + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_delete_by_id_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + + +def build_create_or_update_by_id_request( + schedule_definition_id: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_query_parameters, + headers=_header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_stop_request( + schedule_definition_id: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class AccessReviewScheduleDefinitionsOperations(object): + """AccessReviewScheduleDefinitionsOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AccessReviewScheduleDefinitionListResult"]: + """Get access review schedule definitions. + + :param filter: The filter to apply on the operation. Other than standard filters, one custom + filter option is supported : 'assignedToMeToReview()'. When one specified + $filter=assignedToMeToReview(), only items that are assigned to the calling user to review are + returned. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewScheduleDefinitionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinitionListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewScheduleDefinitionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions"} # type: ignore + + @distributed_trace + def get_by_id( + self, + schedule_definition_id: str, + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": + """Get single access review definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewScheduleDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_get_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def delete_by_id( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Delete access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_delete_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def create_or_update_by_id( + self, + schedule_definition_id: str, + properties: "_models.AccessReviewScheduleDefinitionProperties", + **kwargs: Any + ) -> "_models.AccessReviewScheduleDefinition": + """Create or Update access review schedule definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param properties: Access review schedule definition properties. + :type properties: + ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinitionProperties + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AccessReviewScheduleDefinition, or the result of cls(response) + :rtype: ~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewScheduleDefinition + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewScheduleDefinition"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(properties, 'AccessReviewScheduleDefinitionProperties') + + request = build_create_or_update_by_id_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AccessReviewScheduleDefinition', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update_by_id.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}"} # type: ignore + + + @distributed_trace + def stop( # pylint: disable=inconsistent-return-statements + self, + schedule_definition_id: str, + **kwargs: Any + ) -> None: + """Stop access review definition. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + + request = build_stop_request( + schedule_definition_id=schedule_definition_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.stop.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + stop.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/stop"} # type: ignore + diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py new file mode 100644 index 000000000000..ee1fcb66cb0a --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_operations.py @@ -0,0 +1,145 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/operations") + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class Operations(object): + """Operations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists the operations available from this provider. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/operations"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py new file mode 100644 index 000000000000..c103770006aa --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/operations/_tenant_level_access_review_instance_contacted_reviewers_operations.py @@ -0,0 +1,164 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + schedule_definition_id: str, + id: str, + **kwargs: Any +) -> HttpRequest: + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + accept = "application/json" + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers") # pylint: disable=line-too-long + path_format_arguments = { + "scheduleDefinitionId": _SERIALIZER.url("schedule_definition_id", schedule_definition_id, 'str'), + "id": _SERIALIZER.url("id", id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_query_parameters, + headers=_header_parameters, + **kwargs + ) + +class TenantLevelAccessReviewInstanceContactedReviewersOperations(object): + """TenantLevelAccessReviewInstanceContactedReviewersOperations 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.authorization.v2021_07_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): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + schedule_definition_id: str, + id: str, + **kwargs: Any + ) -> Iterable["_models.AccessReviewContactedReviewerListResult"]: + """Get access review instance contacted reviewers. + + :param schedule_definition_id: The id of the access review schedule definition. + :type schedule_definition_id: str + :param id: The id of the access review instance. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either AccessReviewContactedReviewerListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.authorization.v2021_07_01_preview.models.AccessReviewContactedReviewerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = kwargs.pop('api_version', "2021-07-01-preview") # type: str + + cls = kwargs.pop('cls', None) # type: ClsType["_models.AccessReviewContactedReviewerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + schedule_definition_id=schedule_definition_id, + id=id, + api_version=api_version, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AccessReviewContactedReviewerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDefinition, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.Authorization/accessReviewScheduleDefinitions/{scheduleDefinitionId}/instances/{id}/contactedReviewers"} # type: ignore diff --git a/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/authorization/azure-mgmt-authorization/azure/mgmt/authorization/v2021_07_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file